We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46039
    • 76 Posts
    Is this call valid?

    [[!FormIt? 
    &hooks=`email,redirect` 
    &emailTpl=`contactus.tpl` 
    &emailFrom=`[email protected]` 
    &emailFromName=`domain.org.uk Customer Enquiry`
    &emailTo=`[email protected],[[+addressTo]]` 
    &emailSubject=`domain.org.uk Customer Enquiry` 
    &emailReplyTo=`[[+email]]`
    &validate=`name:required,
          email:email:required,
          message:required:stripTags,
          tel:isNumber`
    &validationErrorMessage=`Please review the form for the following errors: [[+errors]]` 
    &submitVar=`contact-form`
    &redirectTo=`29` 
    ]]
    


    Can you see where I'm using placeholders from the form, [[+addressTo]], or where I've used [[+errors]]... They're always empty, they never return a value.

    Within the form they read like this (however the fact +errors doesn't work makes me think it's not a syntax error:

    <option value="[email protected]" [[!+fi.addressTo:FormItIsSelected=`[email protected]`]]>option 1</option>
    


    I'm completely baffled by this issue, any help would be massively appreciated.

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

    [ed. note: johnnyp last edited this post 12 years, 7 months ago.]
      • 42562
      • 1,145 Posts
      Why are you using [[+addressTo]] with only one email address?
      &emailTo=`[email protected],[[+addressTo]]`
      // if [[+addressTo]] has no content elsewhere on the page, it will always be empty


      Try this instead...
      [[!FormIt?
         &emailTo=`[[+addressTo]]`
      ]]
      ...
      <select name="addressTo">
         <option value="[email protected]" [[!+fi.addressTo:FormItIsSelected=`[email protected]`]]>Admin Pro</option>
         <option value="[email protected]" [[!+fi.addressTo:FormItIsSelected=`[email protected]`]]>Huncho Head</option>
      </select>

      This will send the email to whoever is selected in the "addressTo" field.
      http://rtfm.modx.com/extras/revo/formit/formit.hooks/formit.hooks.email

      [[+errors]]
      syntax + spelling?

      Try this instead...
      I think you use this for the whole form
      Please review the form for the following errors: [[!+fi.error_message]]

      And
      [[!+fi.error.name]]

      for individual fields... test and see what happens


      http://rtfm.modx.com/extras/revo/formit/formit.tutorials-and-examples/formit.examples.simple-contact-page
        TinymceWrapper: Complete back/frontend content solution.
        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
        • 46039
        • 76 Posts
        I'm not only using it with one address, I have a huge list – just didnt see the point in pasting it all in here when the important parts are the same.

        Changing the errors placeholder did nothing. When the validation fails, and the page returns, [[!+fi.validation_error_message]] returns fine in the page, but the placeholder [[+errors]] within it returns nothing.
          • 46039
          • 76 Posts
          Error log:
           [2014-02-28 16:45:05] (ERROR @ /home/sites/domain.org.uk/public_html/core/cache/includes/elements/modsnippet/5.include.cache.php : 39) PHP warning: in_array() expects parameter 2 to be array, string given
          [2014-02-28 16:45:05] (ERROR @ /home/sites/domain.org.uk/public_html/core/cache/includes/elements/modsnippet/5.include.cache.php : 39) PHP warning: in_array() expects parameter 2 to be array, string given
          [2014-02-28 16:45:08] (ERROR @ /home/sites/domain.org.uk/public_html/core/cache/includes/elements/modsnippet/5.include.cache.php : 39) PHP warning: in_array() expects parameter 2 to be array, null given
          [2014-02-28 16:45:08] (ERROR @ /home/sites/domain.org.uk/public_html/core/cache/includes/elements/modsnippet/5.include.cache.php : 39) PHP warning: in_array() expects parameter 2 to be array, null given
          
            • 46039
            • 76 Posts
            Anyone got any ideas? This is the file (and yes I hard reset the cache a thousand times):

            <?php
            function elements_modsnippet_5($scriptProperties= array()) {
            global $modx;
            if (is_array($scriptProperties)) {
            extract($scriptProperties, EXTR_SKIP);
            }
            /**
             * FormIt
             *
             * Copyright 2009-2012 by Shaun McCormick <[email protected]>
             *
             * FormIt is free software; you can redistribute it and/or modify it
             * under the terms of the GNU General Public License as published by the Free
             * Software Foundation; either version 2 of the License, or (at your option) any
             * later version.
             *
             * FormIt is distributed in the hope that it will be useful, but WITHOUT ANY
             * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
             * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
             *
             * You should have received a copy of the GNU General Public License along with
             * FormIt; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
             * Suite 330, Boston, MA 02111-1307 USA
             *
             * @package formit
             */
            /**
             * Custom output filter that returns checked="checked" if the value is set
             *
             * @var string $input
             * @var string $options
             * @package formit
             */
            $output = ' ';
            if ($input == $options) {
                $output = ' selected="selected"';
            }
            $input = $modx->fromJSON($input);
            if (in_array($options,$input)) {
              $output = ' selected="selected"';
            }
            return $output;
            }
            


            Very confusing. To recap – If I specify an email address in emailTo the form sends fine – but any placeholders within the FormIt snippet (example [[+addressTo]]) call don't get filled.
              • 3109 ☆ A M B ☆
              • 894 Posts
              johnnyp can you post your form html?

              Try adding a this to your select to see if it works:

              value="[[+addressTo]]"
              


              I think the errors placeholder doesn't know there's an error due to the way FormIt handles selects.

              You can also check my FormIt tutorial if you want to use custom error messages.
                Benjamin Marte
                Interactive Media Developer
                Follow Me on Twitter | Visit my site | Learn MODX
                • 46039
                • 76 Posts
                Hey benmarte, that made no difference sadly. Here's my form HTML:

                <form action="[[~[[*id]]]]" method="post">
                    <fieldset>
                        <select name="addressTo" required="">
                            <option value="" disabled selected>Subject of Enquiry</option>
                            <option value="[email protected]" [[!+fi.addressTo:FormItIsSelected=`[email protected]`]]>1</option>
                            <option value="[email protected]" [[!+fi.addressTo:FormItIsSelected=`[email protected]`]]>2</option>
                        </select>
                        <label for="name" >Your Name</label>
                        <input id="name" name="name" value="[[!+fi.name]]" placeholder="Your Name"><span class="error">[[!+fi.error.name]]</span>
                        <label for="email" >Your Email</label>
                        <input id="email" name="email" type="email" value="[[!+fi.email]]" placeholder="Your Email Address"><span class="error">[[!+fi.error.email]]</span>
                        <label for="tel" >Your Phone Number</label>
                        <input id="tel" name="tel" type="tel" value="[[!+fi.tel]]" placeholder="Your Phone Number"><span class="error">[[!+fi.error.tel]]</span>
                        <label for="message" >Your Message</label>
                        <textarea id="message" name="message" type="text" value="[[!+fi.message]]" maxlength="500" title="" placeholder="Your Message"></textarea><span class="error">[[!+fi.error.message]]</span>
                        <input name="contact-form" type="submit" value="Send">
                    </fieldset>
                </form>
                
                  • 3109 ☆ A M B ☆
                  • 894 Posts
                  I just copied your formit call and your forms code and I removed the redirect and the tel:isNumber and it works fine, error messages returned just fine.

                  Weird.
                    Benjamin Marte
                    Interactive Media Developer
                    Follow Me on Twitter | Visit my site | Learn MODX
                    • 46039
                    • 76 Posts
                    It's definitely some deeper issue. I can't really understand the error message in the log.
                    I have no idea what to do next.
                      • 3109 ☆ A M B ☆
                      • 894 Posts
                      Have you tried uninstalling and removing FormIt then re-installing? Might be worth a try I got nothing, sorry.
                        Benjamin Marte
                        Interactive Media Developer
                        Follow Me on Twitter | Visit my site | Learn MODX