We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21078
    • 77 Posts
    Today I discovered a very strange behaviour of FormIt. I never experienced this before with numerous MODX-pages I developed so far. I wanted to create a simple contact form, using the hooks "spam" and "email". But FormIt did not render any output. I deleted all parameters except "&hooks" and suddenly it worked. So I added the parameters line by line and checking when exactly FormIt stopped working. I discovered that the error occurs while using mail-addresses within parameters like &emailTo or &emailFrom etc. Replacing the static mail-addresses with placeholders like [[++emailsender]] doesn't work either. I have no clue what the problem might be ... sad

    Here is my call of FormIt:

    [[!FormIt? 
    &hooks=`spam,email` 
    &spamEmailFields=`mail` 
    &emailTpl=`KontaktformularMail` 
    &emailSubject=`Anfrage über Kontaktformular` 
    &emailFrom=`[email protected]` 
    &emailFromName=`Formmailer` 
    &emailHtml=`0` 
    &emailTo=`[email protected]` 
    &emailBCC=`[email protected]` 
    &successMessage=`Vielen Dank für Ihre Nachricht, wir werden uns in Kürze bei Ihnen melden.` 
    &validationErrorMessage=`Ihre Nachricht konnte nicht gesendet werden. Bitte überprüfen Sie Ihre Eingaben.` 
    &validate=`anrede:required,
    vorname:required,
    name:required,
    strasse:required,
    plzort:required,
    telefon:required,
    mail:email:required,
    nachricht:required:stripTags`
    ]]
    
    <!-- Contact Form -->
    <section id="contact">
    
      <!-- Success Message -->
      [[!+fi.successMessage:notempty=`<mark id="message">[[!+fi.successMessage]]</mark>`]]
      [[!+fi.validation_error_message:notempty=`<mark id="message">[[!+fi.validation_error_message]]</mark>`]]
      
      <!-- Form -->
      <form action="[[~[[*id]]]]" method="post" name="contactform" id="contactform">
    
      	<input type="hidden" name="nospam:blank" value="[[+fi.nospam]]">
    	
    	<fieldset>
    
    	  <div>
    	  	<label for="anrede">Anrede: <span>*</span></label>
    		<select name="anrede" id="anrede" value="[[!+fi.anrede]]">
    		  <option value="Herr" [[!+fi.anrede:FormItIsSelected=`Herr`]]>Herr</option>
    		  <option value="Frau" [[!+fi.anrede:FormItIsSelected=`Frau`]]>Frau</option>
    		</select>
    		[[!+fi.error.anrede:notempty=`<br><span class="error">[[!+fi.error.anrede]]</span>`]]
    	  </div>
    	  
    	  <div>
    		<label for="vorname">Vorname: <span>*</span></label>
    		<input name="vorname" type="text" id="vorname" value="[[!+fi.vorname]]" placeholder="Ihr Vorname" required="required">
    	  </div>
    
    	  <div>
    		<label for="name">Name: <span>*</span></label>
    		<input name="name" type="text" id="name" value="[[!+fi.name]]" placeholder="Ihr Nachname" required="required">
    	  </div>
    
    	  <div>
    		<label for="strasse">Straße: <span>*</span></label>
    		<input name="strasse" type="text" id="strasse" value="[[!+fi.strasse]]" placeholder="Ihre Straße" required="required">
    	  </div>
    
    	  <div>
    		<label for="plzort">PLZ / Ort: <span>*</span></label>
    		<input name="plzort" type="text" id="plzort" value="[[!+fi.plzort]]" placeholder="Ihr PLZ / Ort" required="required">
    	  </div>
    
    	  <div>
    		<label for="telefon">Telefon: <span>*</span></label>
    		<input name="telefon" type="text" id="telefon" value="[[!+fi.telefon]]" placeholder="Ihre Telefonnummer" required="required">
    	  </div>
    	  
    	  <div>
    		<label for="mail">E-Mail: <span>*</span></label>
    		<input name="mail" type="email" id="mail" pattern="^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$" value="[[!+fi.mail]]" placeholder="Ihre E-Mail" required="required">
    	  </div>
    	  
    	  <div>
    		<label for="nachricht">Nachricht: <span>*</span></label>
    		<textarea name="nachricht" cols="40" rows="3" id="nachricht" spellcheck="true" value="[[!+fi.nachricht]]" placeholder="Ihre Nachricht" required="required"></textarea>
    	  </div>
    	  
    	</fieldset>
    	
    	<input type="submit" class="submit" id="submit" value="Nachricht senden" />
    	<div class="clearfix"></div>
    	
      </form>
      
    </section>
    <!-- Contact Form / End -->
    


    MODX error log doesn't receive any messages and QuickEmail works just fine. Can someone help me please? Thank you!

    This question has been answered by Nebulous. See the first response.

    [ed. note: Nebulous last edited this post 10 years, 11 months ago.]
      L.net Web Solutions
      Professional webdesign and development with MODX and WordPress.
      • 47401
      • 295 Posts
      in the &validate you need to ensure that nospam:empty is set. also in your form ensure the following input field is there:

      <input type="hidden" name="nospam"/>


      what the formit code is doing is trying to find the hidden input field, becuase it cant it will halt the process.
        • 21078
        • 77 Posts
        Yes, this hidden field is available. Take a look at my edited post - I added the form markup.
          L.net Web Solutions
          Professional webdesign and development with MODX and WordPress.
          • 3749
          • 24,544 Posts
          I wonder if the umlout in &emailSubject=`Anfrage über Kontaktformular` is causing the trouble. I'm not sure what FormIt uses to validate that field, but it might be a regex that fails there.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 21078
            • 77 Posts
            Quote from: BobRay at Oct 22, 2015, 03:54 PM
            I wonder if the umlout in &emailSubject=`Anfrage über Kontaktformular` is causing the trouble. I'm not sure what FormIt uses to validate that field, but it might be a regex that fails there.

            Hm, no. sad As I wrote in my opening post the form gets rendered while I delete all parameters that include mail-addresses. So this will not work:

            [[!FormIt? 
            	&hooks=`spam,email`
            	&spamEmailFields=`mail`
            	&emailTpl=`KontaktformularMail`
            	&emailSubject=`Anfrage über Kontaktformular`
            	&emailHtml=`0`
            	&emailFrom=`[[++emailsender]]`
            	&emailFromName=`[[++site_name]]`
            	&emailTo=`[email protected]`
            	&emailBCC=`[email protected]`
            	&successMessage=`Vielen Dank für Ihre Nachricht, wir werden uns in Kürze bei Ihnen melden.`
            	&validationErrorMessage=`Ihre Nachricht konnte nicht gesendet werden. Bitte überprüfen Sie Ihre Eingaben.`
            	&validate=`anrede:required,
            		vorname:required,
            		name:required,
            		strasse:required,
            		plzort:required,
            		telefon:required,
            		email:email:required,
            		nachricht:required:stripTags`
            ]]


            But this will work (deleted parameters &emailFrom, &emailTo and &emailBCC):

            [[!FormIt? 
            	&hooks=`spam,email`
            	&spamEmailFields=`mail`
            	&emailTpl=`KontaktformularMail`
            	&emailSubject=`Anfrage über Kontaktformular`
            	&emailHtml=`0`
            	&emailFromName=`[[++site_name]]`
            	&successMessage=`Vielen Dank für Ihre Nachricht, wir werden uns in Kürze bei Ihnen melden.`
            	&validationErrorMessage=`Ihre Nachricht konnte nicht gesendet werden. Bitte überprüfen Sie Ihre Eingaben.`
            	&validate=`anrede:required,
            		vorname:required,
            		name:required,
            		strasse:required,
            		plzort:required,
            		telefon:required,
            		email:email:required,
            		nachricht:required:stripTags`
            ]]


            Strange, isn't it?!
              L.net Web Solutions
              Professional webdesign and development with MODX and WordPress.
              • 3749
              • 24,544 Posts
              Yes, especially so since I think FormIt will use the emailsender setting if emailFrom is empty.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 21078
                • 77 Posts
                Yes, but at least I need to set emailTo and that's not possible. sad
                Any further ideas on this issue?
                  L.net Web Solutions
                  Professional webdesign and development with MODX and WordPress.
                • discuss.answer
                  • 21078
                  • 77 Posts
                  Argh. I solved it. I called the chunk containing the FormIt-code this way:

                  [[*pagetitle:is=`Kontakt`:then=`[[$Kontaktformular]]`]]


                  Calling the chunk "Kontaktformular" uncached (or deleting this condition completely) renders the form as expected.
                    L.net Web Solutions
                    Professional webdesign and development with MODX and WordPress.