We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 52050
    • 8 Posts
    stanislav.anv Reply #1, 8 years ago
    Hello!
    There is a problem with several emails in emailTo
    So, what we have

    [[!FormIt?
       &hooks=`spam,emailselector,email,redirect`
       &emailTpl=`recordtpl`
       &emailTo=`[[+emailAddresses]]`
       &emailSubject=`Test email`
       &redirectTo=`118`
       &validate=`name:required,date:required,phone:required`
    ]]



    **SELECT**

    <select class="form-control" name="XOption" value="[[!+fi.XOption]]">
            <option value=""> Option</option>
            <option value="Option_1" [[!+fi.XOption:is=`Option_1:then=`selected`]]>Option_1</option>
            <option value="Option_2" [[!+fi.XOption:is=`Option_2:then=`selected`]]>Option_2</option>
            </select>
     


    **Snippet emailselector (From hooks in from)**


    <?php
    $emailselector = $hook->getValue('XOption');
      
    switch ($emailselector) {
        case "Option_1":
            $hook->setValue('emailAddresses', '[email protected],[email protected]');
            break;
        case "Option_2":
            $hook->setValue('emailAddresses', '[email protected]');
            break;
    }
     
    return true;




    When we try to sent form with 2 emails (Option_1) We can't do that =(
    MODx revo 2.4.3
    Formit 2.2.10-pl

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

    • discuss.answer
      Try this (and remove the emailTo property from the FormIt call):

      <?php
      $emailselector = $hook->getValue('XOption');
         
      switch ($emailselector) {
          case "Option_1":
              $hook->formit->setOption('emailTo', '[email protected],[email protected]');
              break;
          case "Option_2":
              $hook->formit->setOption('emailTo', '[email protected]');
              break;
      }
        
      return true;
      
        • 52050
        • 8 Posts
        stanislav.anv Reply #3, 8 years ago
        Works great! Thank u man!
        Solution is simple! =)