We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15114
    • 102 Posts
    Hi

    I have a form I call like this :

    [!eForm? &formid=`ContactForm` &subject=`Contact A.I.P. : [+objet+]` &to=`[email protected]` &from=`[+email+]` &fromname=`[+nom+]` &tpl=`ContactForm` &report=`ContactFormReport` &invalidClass=`invalidValue` &requiredClass=`requiredValue` &cssStyle=`ContactStyles` &gotoid=`27` !]


    But the placeholders [+objet+], [+email+], [+nom+] are replaced by an empty string. That’s a little bit strange because I’m using exactly the same form on an other website and it works perfectly

    The chunk :

    [+validationmessage+]
    <form method="post" action="[~[*id*]~]" id="EmailForm"><div>
    	<input name="formid" type="hidden" value="ContactForm" />
    
    	<label for="cfNom" class="requiredValue">Votre nom :
    	<input name="nom" id="cfNom"  type="text" eform="Nom:textarea:1" /> </label>
    
    	<label for="cfEmail" class="requiredValue">Votre adresse e-mail :
    	<input name="email" id="cfEmail"  type="text" eform=" adresse e-mail:email:1:L'adresse e-mail n'est pas valide" /> </label>
    
    	<label for="cfObjet" class="requiredValue">Objet du message :
    	<input name="objet" id="cfObjet"  type="text" eform="Objet:textarea:1" /> </label>
    
    	<label for="cfMessage" class="requiredValue">Message: 
    	<textarea name="message" id="cfMessage" rows="4" cols="20" eform="Message:textarea:1"></textarea>
    	</label>
    
    	<label> </label><input type="submit" name="contact" id="cfContact" class="button" value="Envoyer" />
    </div></form>
      • 4172
      • 5,888 Posts
      But the placeholders [+objet+], [+email+], [+nom+] are replaced by an empty string. That’s a little bit strange because I’m using exactly the same form on an other website and it works perfectly

      how do you set these placeholders?
      You need a snippet or plugin which sets these placeholders and runs before these eform-snippet-call is parsed.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 15114
        • 102 Posts
        I haven’t set the placeholders, I have followed this example : http://wiki.modxcms.com/index.php/EForm#A_Simple_ContactForm_chunk
          • 15114
          • 102 Posts
          Solved !

          It was because of PHx, which is enabled on the website where the form doesn’t work.

          In the eForm snippet I saw :

          // pixelchutes PHx workaround
          foreach( $params as $key=>$val ) $params[ $key ] = str_replace( array('((','))'), array('[+','+]'), $val );
          


          so I replaced my eForm call by

          [!eForm? &formid=`ContactForm` &subject=`Contact A.I.P. : ((objet))` &to=`[email protected]` &from=`((email))` &fromname=`((nom))` &tpl=`ContactForm` &report=`ContactFormReport` &invalidClass=`invalidValue` &requiredClass=`requiredValue` &cssStyle=`ContactStyles` &gotoid=`27` !]
          


          and all is Ok now.
            • 10357
            • 573 Posts
            thanks for this! was completely lost as to why my forms had stopped working!
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              And that is why I really don’t like using the PHx plugin.

              However, there is another workaround. The placeholder still exists in the $modx->placeholders array, it’s just that the placeholder tags have been eaten by the PHx garbage collection function (I still strongly suspect a bad regular expression in that code, but I’m not strong enough in regex to be able to confirm or fix that). Anyway, a snippet can be used to retrieve the placeholder directly from the $modx->placeholders[’placeholder-name’] instead of the [+placeholder-name+] tags.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org