We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16868
    • 24 Posts
    The instructions from Mary’s Pad didn’t work for me out of the box either so... here’s what I’m using now, hopefully people can work from it if they’re having issues.

    1. FormIt call (this should be in a chunk which gets called right before your form HTML):

    [[!FormIt?
    &submitVar=`submit`
    &hooks=`email`
    &emailTpl=`doc_uploadtpl`
    &emailSubject=`Work`
    &emailTo=`[email protected]`
    &emailReplyTo=`contact_email`
    &validate=`
      contact_person:minLength=^2^,
      contact_email:email:required,
      contact_company:minLength=^3^,
    &successMessage=`Thanks for your submission!`
    ]]


    2. Email template, also in a chunk, this should not cause problems and can be just about anything. Just make sure it has the same name as the &emailTpl in your FormIt call (above).

    Company: [[+contact_company]]<br />
    Contact: [[+contact_person]]<br />
    Email: [[+contact_email]]<br />


    3. The form HTML (make sure to call your FormIt chunk just above the start of the form!)

    <form id="doc_upload" class="cmxform" method="post" action="[[~[[*id]]]]" enctype="multipart/form-data">
    	<h2>Some Title</h2>
    	<p>Some subtitle</p>
    	<!-- This makes the upload button -->
    	<div>
    		<input id="document" name="document" class="required" type="file" value="[[!+fi.document]]" />
    		<div class="error">[[!+fi.error.document]]</div>
    	</div>
    	<!-- This makes other form fields -->
    	<div>
    		<label for="contact_person">Contact Person: </label>
    		<input id="contact_person" name="contact_person" size="30" class="required" minlength="2" value="[[!+fi.contact_person]]" />
    		<div class="error">[[!+fi.error.contact_person]]</div>
    		<br />
    		<label for="contact_email">Contact Email: </label>
    		<input id="contact_email" name="contact_email" size="30"  class="required email" value="[[!+fi.contact_email]]" />
    		<div class="error">[[!+fi.error.contact_email]]</div>
    		<br />
    		<label for="contact_company">Company Name: </label>
    		<input id="contact_company" name="contact_company" size="30"  class="required" minlength="3" value="[[!+fi.contact_company]]" />
    		<div class="error">[[!+fi.error.contact_company]]</div>
    	</div>
    	<!-- This makes the submit button -->
    	<div class="form_area">
    		<input name="submit" class="submit" type="submit" value="Send"/>
    	</div>
    </form>


    Hope that helps, and please let me know if it doesn’t, I modified it somewhat to be more general so who knows what typos might have slipped in...
      • 12306
      • 16 Posts
      I’ve tried every tutorial available to try to attach a file to email using Formit. I have no idea what I’m doing wrong or if there is a server setting that is conflicting. The basic form above did not work for me. Can anyone help me?
      Thanks!
      Tom
        • 16868
        • 24 Posts
        If you want help you gotta provide info!
          • 12306
          • 16 Posts
          I don’t mind providing info but I’m not sure what else you need. I’ve used the exact same code that is in the post above as well as the exact same code from Mary’s Pad example. Do you want me to repeat code? Could there be a server setting that is interfering? I don’t want to confuse the list by repeating code that is already here. If it were different, then I would totally understand. So, my issue is why the code already posted isn’t working for me? What might stop the attachments from going through? If it helps, all emails are being sent to a Google mail account.
          Modx version = 2.1.0pl (traditional)
          Formit ver = 1.6.0 rc1
          Thanks!
            • 24287
            • 14 Posts
            Quote from: holotrope at Jun 14, 2011, 04:03 PM

            Modx version = 2.1.0pl (traditional)
            Formit ver = 1.6.0 rc1

            I have the same problem with 2.1.1-pl and FormIt 1.6.0 rc1. Could it be that the attachment handling has changed with the new FormIt version? It would be fantastic if someone could come up with a solution.
              • 28215
              • 4,149 Posts
              I’m having no problems with attachments on latest FormIt, guys. Can you be specific in your implementations?
                shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                • 24287
                • 14 Posts
                Hi splittingred,

                thanks for your reply. I use FormIt this way:

                Snippet call:
                [[!FormIt?
                   &hooks=`email`
                   &emailTpl=`FormEmailTest`
                   &emailSubject=Form email test
                   &emailHtml=`1`
                   &emailTo=`XXXXXXXX`
                ]]
                
                <form method="post" action="[[~[[*id]]]]" enctype="multipart/form-data">
                <input type="text" name="something" />
                <input name="attachment" type="file" size="50" maxlength="100000" value="[[!+fi.attachment]]" />
                <input type="submit" />
                </form>


                Template FormEmailTest:
                [[+something]]


                And the email contains the value of [[+something]], but no attachment. I can get the filename with [[+attachment]] in the template, but there’s no file attached in the mail.
                  • 16868
                  • 24 Posts
                  Try tinkering around, there are more suggestions on the forum and at Mary’s Pad that will solve this for you, I know because s had the same problem and was able to solve it.

                  You can start by adding &submitVar=`submit` to your call. Change the submit part to match the name of your submit button (although it’s probably already just submit)

                  Good luck
                    • 22673
                    • 72 Posts
                    I’m having the same issue as rabimoe, IE: attachment filename comes out in the email sent, but nothing attached to the email.

                    [[!FormIt?
                    		&hooks=`email`
                    	        &submitVar=`submit`
                    		&emailTpl=`tplContactReport`
                    		&emailSubject=`Enquiry from the website`
                    		&emailTo=`[email protected]`
                    		&successMessage=`<p class="success">Your message has been sent. Thank you.</p>`
                    		&successMessagePlaceholder=`fi.success`
                    	      ]]
                    	      
                    	      [[!+fi.success]]
                    	      [[!+fi.error.error_message]]
                    	      
                    	      <form action="[[~[[*id]]]]" method="post" id="contactForm" enctype="multipart/form-data">
                    		
                    		<input type="hidden" value="error" />
                    		<div class="field">
                    		  <strong>Full Name*</strong><br />
                    		  <input type="text" name="contactName" class="required" />
                    		</div>
                    			
                    		<div class="field">
                    		  <strong>Email*</strong><br />
                    		  <input type="text" name="contactEmail" class="required" />
                    		</div>
                    		
                    		<div class="field">
                    		  <strong>Phone Number</strong><br />
                    		  <input type="text" name="contactPhone" />
                    		</div>
                    		
                    		<div class="field">
                    		  <strong>CV Upload (if applicable)</strong><br />
                    		  <input type="file" name="contactAttachment" value="[[!+fi.contactAttachment]]" />
                    		</div>
                    		
                    		<div class="field">                    
                    		  <strong>Enquiry*</strong><br />
                    		  <textarea name="contactEnquiry" class="required"></textarea>
                    		</div>
                    		
                    		<div class="field">
                    		  <input type="submit" name="submit" value="Submit" class="submit" />
                    		</div>
                    
                    	      </form>


                    <p><strong>Name:</strong> [[+contactName]]</p>
                    <p><strong>Email:</strong> [[+contactEmail]]</p>
                    <p><strong>Phone:</strong> [[+contactPhone]]</p>
                    <p><strong>Enquiry:</strong> [[+contactEnquiry]]</p>
                    <p>[[+contactAttachment]]</p>


                    MODx 2.1.1-pl traditional
                    Formit 1.6.0-pl
                      • 16868
                      • 24 Posts
                      On quick visual inspection you got two submitvars.

                      Keep trying different stuff, strip other elements away to see if it starts working.