We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    Ambiguous pronouns are the bane of the internet.
    Not just the Internet; they form the basis of one of Agatha Christie’s novels, "The Mirror Crack’d" wink
      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
      • 37514
      • 178 Posts
      Quote from: splittingred at Aug 19, 2010, 11:37 AM

      Quote from: JimKillock at Aug 19, 2010, 11:26 AM

      Is this right or is there a way of inserting the email subject from the form into the email subject line itself?

      It should automatically do that, if you have a field named ’subject’, leave &emailSubject blank, and make sure &emailUseFieldForSubject is set to 1 (the default).

      <snip>
      Placeholders in the subject aren’t supported at this time, but that’s a good idea, and would make a good feature request to file here.

      Thanks, that worked!
        • 37514
        • 178 Posts
        Hi,

        I’m now trying to add recaptcha to the formit. The documentation only says:

        Built-in Hooks

        There are only 3 built-in hooks to FormIt, and they are ’email, ’redirect’ and ’spam’.

        <snip>

        The recaptcha hook

        The recaptcha hook will enabled reCaptcha support for FormIt forms. You’ll need to include the following placeholders in your form:

        view plaincopy to clipboardprint?
        [[+formit.recaptcha_html]]
        [[+fi.error.recaptcha]]
        The first placeholder is where the reCaptcha form will be rendered; the 2nd is the error message (if any) for reCaptcha.

        Finally, you’ll need to setup your reCaptcha private and public keys in System Settings. The settings available for reCaptcha are:

        Name Description
        formit.recaptcha_public_key Your reCaptcha public key.
        formit.recaptcha_private_key Your reCaptcha private key.
        formit.recaptcha_use_ssl Whether or not to use SSL for reCaptcha requests. Defaults to false.

        This seems incomplete - is there something to add to the call, or something additional to install (ie, a hook)?

        Thank you - appreciate the work that’s being done here smiley

        Jim
          • 1778
          • 659 Posts
          Hello Jim

          First you have to get the recaptcha public and private keys on the recaptcha site here :

          http://www.google.com/recaptcha/learnmore (get Recaptcha -> sign up -> follow the steps as indicated....it’s free)

          Once you’ve done you have to fill in the Revo System Settings (find recaptcha with the search field) with your keys...

          And normally it rocks !

          BTW I think a little paragraph on how to get the recaptcha keys would be useful in the doc wink
            • 37514
            • 178 Posts
            Quote from: anso at Aug 20, 2010, 04:56 AM

            ... First you have to get the recaptcha public and private keys
            <snip>
            Once you’ve done you have to fill in the Revo System Settings (find recaptcha with the search field) with your keys...
            <snip>

            Hi Anso, So I’ve:

            1 Added the recaptcha tags,
            <textarea id="text" cols="55" rows="7" name="text:required:stripTags">[[+fi.text]]</textarea>  
                    <label> </label><input id="cfContact" class="button" name="submitContact" type="submit" value="Send This Message" />
            [[+formit.recaptcha_html]]  
            [[+fi.error.recaptcha]]      </fieldset></form>


            2 Added the recaptcha settings in the manager (formit.recaptcha_private_key, formit.recaptcha_public_key)

            3 Left the call unchanged:
            [[!FormIt? &hooks=`spam,email,redirect` &emailTpl=`ContactFormReport` &emailTo=`[[++emailsender]]` &redirectTo=`15` &submitVar=`submitContact` &emailUseFieldForSubject=`1` ]]

            Currently the recaptcha doesn’t display. Is there definitely not a third step, to the call? Or have I done something else wrong (the recaptcha keys work elsewhere on the Quip comments)?

              • 1778
              • 659 Posts
              Yep you have to set the hook !
              [[!FormIt? &hooks=`recaptcha,spam,email,redirect` &emailTpl=`ContactFormReport` &emailTo=`[[++emailsender]]` &redirectTo=`15` &submitVar=`submitContact` &emailUseFieldForSubject=`1` ]]
              


              Cheers
                • 37514
                • 178 Posts
                Thanks Anso, that worked! The manual’s down right now, but I’ll take another look and see if I missed that, or if it wasn’t clear. Thank you again!
                  • 1778
                  • 659 Posts
                  Glad if it works... Enjoy!
                    • 12487
                    • 3 Posts
                    There is Hope!

                    Hacked it to work so it can send to email addresses specified from the form itself.

                    I know it is not safe yet as it doesn’t sanitize or check input to prevent any user-submitted nastiness, but if you need it as a jumping off point here is what I did.

                    edit the file core/components/formit/model/formit/fihooks.class.php where it says "/* check email to */" as follows:

                      
                    /* check email to */
                    // custom mod to get it to send email to value from a form field
                            $emailToField = $this->modx->getOption('emailToField',$this->formit->config,$emailToField);
                            if (!empty($emailToField)) {
                                $emailTo = $fields[$emailToField];
                            }
                            else {
                            $emailTo = $this->modx->getOption('emailTo',$this->formit->config,'');
                            }
                    


                    then in your snippet call, add a parameter for &emailToField and pass it the name of the form field you want to use for the To. (ex: &emailToField =`addresses`)

                    Again, this has only be tested for one particular case but it worked for what I needed it to do. Since it is reassigning values to $emailTo before the validation is applied, the rules should still apply and since support is added for multiple To’s when comma separated, it should work for most cases.

                    I will submit to github as well and maybe someone can refine from there (tho slammed and never done it before, so may be a later in the week)

                    Hope it helps someone out. Thanks for a great base to work with (eForm used to drive me nuts)
                      • 15193
                      • 9 Posts
                      Hi!

                      Should this script save filled form data to a cookie or db?
                      If user forgets fill required field the script will empty all fields and user must refill every field again.