We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40088
    • 708 Posts
    I have a working form and I want to pass the name of the sender to the success message which appears on the same page (no redirects).

    Success Message:
    &successMessage=`<div class="alert alert-success">
    	<p>Thank you, [[sender_name_here]]. Your message has been sent.</p>
    </div>`

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

      Todd
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      [[+name]] (or whatever the name input field's actual name is) should work in the &successMessage property.
        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
        • 40088
        • 708 Posts
        Hmmm, already tried that one. No luck.
          Todd
          • 36996
          • 211 Posts
          Try a custom hook:
          $name = $hook->getValue('fullname');
          
            • 40088
            • 708 Posts
            Thank you.

            I've been reading about custom hooks but I'm still learning how to implement them. I'll try your suggestion once I understand it better.
              Todd
            • discuss.answer
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Here's how to do it. Note the FormItRetriever snippet, and the &store=`1` property, also the uncached [[!fi.name]] placeholder.
              [[!FormItRetriever]]
              [[!FormIt?
                 &hooks=`spam,email`
                 &emailTpl=`formMailTpl`
                 &emailSubject=`Website Contact`
                 &emailTo=`[email protected]`
                 &emailFrom=`[[++emailsender]]`
                 &emailFromName=`[[++site_name]]`
                 &emailReplyTo=`[[+email]]`
                 &emailReplyToName=`[[+name]]`
                 &store=`1`
                 &successMessage=`Thank you, [[!+fi.name]], Your message has been sent.`
                 &validate=`name:required,
                    email:email:required,
                    text:required:stripTags`
              ]]
              

              http://rtfm.modx.com/extras/revo/formit/formit.formitretriever
                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
                • 40088
                • 708 Posts
                Susan, I used your example code and everything seems to work except that there is still no name in the success message. Odd, isn't it?
                  Todd
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Very. I tried it and it worked fine. Are you sure the name attribute of the form field is "name"?
                    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
                    • 40088
                    • 708 Posts
                    Quote from: sottwell at Jun 23, 2014, 04:39 PM
                    Are you sure the name attribute of the form field is "name"?

                    Positive.

                    I'll try again. Obviously if it's working for you then I must be overlooking something, but I'll suss it out ... eventually.

                    Thank you.
                      Todd