We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23050
    • 1,842 Posts
    Hello,

    I get the error formit.email_no_recipient when validating a form with FormIt whereas &emailTo is ok on FormIt call.

    I run MODX Revolution 2.2.0-pl2 (traditional) on PHP Version 5.2.17
    FormIt version is 2.2.0

    Here are the call and form :

    [[!FormIt?
       &hooks=`spam,email,FormItAutoResponder,redirect`
       &emailTpl=`formitCentury21MailTPL`
       &emailSubject=`Nouveau contact`
       &emailTo=`[email protected]`
       &emailToName=`Perrine`
       &emailFrom=`[email protected]`
       &emailFromName=`Street Finances`
       &fiarTpl=`formitCentury21FiarTPL`
       &fiarSubject=`Votre message`
       &fiarFrom=`[email protected]`
       &fiarFromName=`Street Finances`
       &redirectTo=`23`
       &validate=`nom:required,
          email:email:required,
          message:required:stripTags,
          telephone:required`
    ]]
    
    [[!+fi.error_message:notempty=`<p>[[!+fi.error_message]]</p>`]]
     
    <form action="[[~[[*id]]]]" method="post" class="form" style="margin-top:25px">
        <input type="hidden" name="nospam:blank" value="" />
    
    
        <div class="champ checkbox" style="margin-bottom:15px;">
          <input style="margin-left:150px" id="rech-financement" type="checkbox" name="demande[]" value="Recherche financement" [[!+fi.demande:FormItIsChecked=`Recherche financement`]] />
          <label style="float:none;color:#660033;font-size: 1.1em;" for="rech-financement">Je recherche un financement pour un projet immobilier</label>
        </div>
    
        <div class="champ checkbox" style="margin-bottom:15px;">
          <input style="margin-left:150px" id="rech-defiscalisation" type="checkbox" name="demande[]" value="Recherche défiscalisation" [[!+fi.demande:FormItIsChecked=`Recherche défiscalisation`]] />
          <label style="float:none;color:#660033;font-size: 1.1em;" for="rech-defiscalisation">Je recherche des solutions de défiscalisation</label>
        </div>
    
        <div class="champ checkbox" style="margin-bottom:15px;">
          <input style="margin-left:150px" id="rech-credits" type="checkbox" name="demande[]" value="Recherche crédits" [[!+fi.demande:FormItIsChecked=`Recherche crédits`]] />
          <label style="float:none;color:#660033;font-size: 1.1em;" for="rech-credits">Je souhaite regrouper mes crédits, et/ou renégocier mes crédits à un meilleur taux</label>
        </div>
     
        <div class="champ">
          <label for="nom"><span class="req">*</span>Nom : 
              <span class="error">[[!+fi.error.nom]]</span>
          </label>
          <input type="text" name="nom" id="nom" value="[[!+fi.nom]]" />
        </div>
     
        <div class="champ">
          <label for="prenom">Prénom : 
          </label>
          <input type="text" name="prenom" id="prenom" value="[[!+fi.prenom]]" />
        </div>
     
        <div class="champ">
          <label for="telephone"><span class="req">*</span>Téléphone : 
              <span class="error">[[!+fi.error.telephone]]</span>
          </label>
          <input type="text" name="telephone" id="telephone" value="[[!+fi.telephone]]" />
        </div>
    
        <div class="champ">
          <label for="ville">Ville : 
          </label>
          <input type="text" name="ville" id="ville" value="[[!+fi.ville]]" />
        </div>
    
        <div class="champ">
          <label for="cp">Code Postal : 
          </label>
          <input type="text" name="cp" id="cp" value="[[!+fi.cp]]" />
        </div>
     
        <div class="champ">
          <label for="email"><span class="req">*</span>E-mail : 
              <span class="error">[[!+fi.error.email]]</span>
          </label>
          <input type="text" name="email" id="email" value="[[!+fi.email]]" />
        </div>
     
        <div class="champ">
          <label for="profession">Profession : 
          </label>
          <input type="text" name="profession" id="profession" value="[[!+fi.profession]]" />
        </div>
    
        <div class="champ">
          <label for="societe">Société : 
          </label>
          <input type="text" name="societe" id="societe" value="[[!+fi.societe]]" />
        </div>
     
        <div class="champ">
          <label for="message">Comment vous contacter ?
              <span class="error">[[!+fi.error.message]]</span>
          </label>
          <textarea id="message" name="message" value="[[!+fi.message]]" rows="7" style="width:400px;"></textarea>
        </div>
    
     
        <br class="clear" />
     
        <div class="form-buttons">
            <input type="image" value="Envoyez" src="images/btn-envoyez.jpg" />
        </div>
    </form>


    I also get an error in error log. Don't know if errors are related :

    [2013-07-08 13:52:35] (ERROR @ /index.php) [FormIt] Spécifiez un ou plusieurs destinataires du courriel.
    [2013-07-08 13:52:35] (ERROR @ /web/xxx/www/core/cache/includes/elements/modsnippet/10.include.cache.php : 39) PHP warning: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument
    [2013-07-08 13:52:35] (ERROR @ /web/xxx/www/core/cache/includes/elements/modsnippet/10.include.cache.php : 39) PHP warning: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument
    [2013-07-08 13:52:35] (ERROR @ /web/xxx/www/core/cache/includes/elements/modsnippet/10.include.cache.php : 39) PHP warning: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument


    And here is the 10.include.cache.php :
    <?php
    function elements_modsnippet_10($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 = ' checked="checked"';
    }
    $input = $modx->fromJSON($input);
    if (in_array($options,$input)) {
      $output = ' checked="checked"';
    }
    return $output;
    }


    Don't know how to debug it... When I desactivate email hook, form passes validation !

    Thank you smiley
      • 37105
      • 194 Posts
      I had such an error about arrays. In the Github of Formit I noticed a little fix in 2 snippets which FormIt uses. These snippets are FormItIsChecked and FormItIsSelected.

      Change line 34 in both snippets:

      from

      if (in_array($options,$input)) {


      to

      if ( is_array($input) && in_array($options, $input) ) {


        Codeplaza Webdesign: for professional websites at low cost
        • 23050
        • 1,842 Posts
        Thanks you for your help DonQuicky but it didn't resolve my problem... I still got the message with error formit.email_no_recipient

        But, I finally found the problem. I was adding shockedbfuscateemail to my [[*content]]
        I guess it was encoding the "to" email and couldn't deliver the mail.

        Too bad... laugh