We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Using the basic example is functional as it is. It leaves me with a number of questions regarding placeholders and messages, however.

    1. In the snippet, can the form field placeholders be used as values for the parameters, for example for the emailSubject parameter can the "fi.subject" placeholder be used? Or is there some other way the value of that field can be used?

    2. The fi.error.error_message placeholder doesn’t display anything, although the individual field error placeholders are displaying the appropriate messages just fine.

    3. Using the fi.success placeholder (without a redirect) just displays a "1".

      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
      • 28215
      • 4,149 Posts
      Quote from: sottwell at Sep 08, 2010, 03:02 AM

      1. In the snippet, can the form field placeholders be used as values for the parameters, for example for the emailSubject parameter can the "fi.subject" placeholder be used? Or is there some other way the value of that field can be used?
      If you have a field named ’subject’ in your form, you can use [[+subject]] in your email template or subject line - ie, &emailSubject=`Subject: [[+subject]]`. (although, FormIt automatically checks for the field ’subject’ and uses its value if &emailUseFieldForSubject is set to 1, which it is by default. So make sure to set &emailUseFieldForSubject to 0 to override the subject if you have a subject field.)

      2. The fi.error.error_message placeholder doesn’t display anything, although the individual field error placeholders are displaying the appropriate messages just fine.
      The fi.error.error_message placeholder is mainly for hooks to report when they have an error message.

      3. Using the fi.success placeholder (without a redirect) just displays a "1".
      Correct - you could use Output Filters to display your own message:

      [[+fi.success:notempty=`Thanks for submitting the form!`]]
      



        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
      • If you have a field named ’subject’ in your form, you can use [[+subject]] in your email template or subject line - ie, &emailSubject=`Subject: [[+subject]]`. (although, FormIt automatically checks for the field ’subject’ and uses its value if &emailUseFieldForSubject is set to 1, which it is by default. So make sure to set &emailUseFieldForSubject to 0 to override the subject if you have a subject field.)

        So you are saying that with no &emailSubject parameter it should use the subject field as the email subject by default? Hm. It’s not. My mail is coming in with a blank subject field. Here’s the snippet call (I’m using the example form):
        [[!FormIt?
           &hooks=`spam,email`
           &emailTpl=`MyEmailChunk`
           &emailTo=`[email protected]`
        ]]

        I do have the email chunk using the [[+fi.subject]] placeholder, and it’s working there as expected.

          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
          • 28215
          • 4,149 Posts
          You have a subject field with the name of ’subject’?

          What’s your form look like?
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
          • As I mentioned, using [[+fi.subject]] in the mail chunk works as expected.
            <p>[[+fi.error.error_message]]</p> 
                    <form id="cForm" action="[[~[[*id]]]]" method="post" class="cform">
                    <fieldset class="input">
                        <input type="hidden" name="nospam:blank" value="" />
            
                        <label for="name">
                            Name:
                            <span class="error">[[+fi.error.name]]</span>
                        </label>
                        <input type="text" class="text" name="name:required" id="name" value="[[+fi.name]]" />
            
                        <label for="email">
                            Email:
                            <span class="error">[[+fi.error.email]]</span>
                        </label>
                        <input type="text" class="text" name="email:email:required" id="email" value="[[+fi.email]]" />
            
                        <label for="subject">
                            Subject:
                            <span class="error">[[+fi.error.subject]]</span>
                        </label>
                        <input type="text" class="text" name="subject:required" id="subject" value="[[+fi.subject]]" />
            
                        <label for="text">
                            Message:
                            <span class="error">[[+fi.error.text]]</span>
                        </label>
                        <textarea name="text:required:stripTags" id="text" cols="60" rows="7" value="[[+fi.text]]">[[+fi.text]]</textarea>
                    </fieldset>
            
                        <fieldset class="form-buttons">
                            <input type="submit" class="button" value="Send Contact Inquiry" />
                        </fieldset>
            
                    </form>
              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
              • 28883
              • 35 Posts
              I know this thread is quite old but it is still somewhat relevant. I've got a very basic form and have just tried to implement reCaptcha. Everything is working perfectly except for one thing...

              I quickly mention that I make use of the success placeholder. If the one is returned, I use the jquery load function to display a thank you message from another modx page (this page also contains the google conversion code). I only do this because my clients do no want the visitor to be redirected to another page.

              That being said, if I enter the correct phrase into the reCaptcha input, the form refreshes and the form sends...and of course the success placeholder is updated with the "1" (all good).

              If I enter the incorrect phrase into the reCaptcha input, the page refreshes but the form does not send...and I get my error message (all good). The problem is, the success placeholder still gets populated with a '1' - despite the fact that reCaptcha has failed. The docs tell me that the hooks are executed in sequence...that if a hoook fails, the rest of them don't execute. If this is true, am I correct in assuming that I shouldn't be getting a '1'?

              Here is my snippet call:

              [[!FormIt?
              &hooks=`recaptcha,spam,email`
              &validate=`phone:blank`
              &recaptchaTheme=`white`
              &emailTpl=`EmailTemplate`
              &emailSubject=`Some Enquiry`
              &emailFrom=`[[+email1]]`
              &emailTo=`[email protected]`
              ]]

              I've noticed on the reCaptcha docs that one can return a success message - is there any way for me to do that via the modx snippet (as an alternative to my current solution)?

              Any insight or assistance will be greatly appreciated! [ed. note: supanick last edited this post 12 years, 8 months ago.]
                • 28883
                • 35 Posts
                I can hear crickets...anyone out there:)
                  • 3749
                  • 24,544 Posts
                  Do you have the current version of FormIt? There was a bug in earlier versions that allowed hooks to work execute after an earlier one had failed.

                  Also, I think you should be adding this to the FormIt tag:

                  &successMessage=`Message Sent`


                  You'll also need this placeholder in the form:

                  	[[+fi.successMessage]]
                    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