We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53212
    • 4 Posts
    Hey guys,

    I've got a question about a custom FormIt snippet. I'm trying to create a hook which allows for adding an emailCC based on a custom filter. In my form I've got a field1020 dropdown box which contains a list of all countries. Besides that I've a snippet which acts as a custom hook. I've attached the custom hook to the formit form. No problems so far. I've tested out the switch statement and I actually end up in the Netherlands case once I select that value in the dropdown.

    The problem is that the formit options function doesn't seem to be working. The emailCC value isn't being set. Anyone got any suggestions for me?

    <?php
    
    $country = $hook->getValue('field1020');
    
    switch($country){
    
    case "France": 
     $hook->formit->options['emailCC'] = '[email protected]';
    break;
    
    case "Netherlands":
     $hook->formit->options['emailCC'] = '[email protected]';
    break;
    }
    
    return true;


    kind regards

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

      • 37105
      • 194 Posts
      You can try the setValues option to the hook.

      <?php
       
      $country = $hook->getValue('field1020');
       
      switch($country){
       
      case "France": 
       $email = '[email protected]';
      break;
       
      case "Netherlands":
       $email = '[email protected]';
      break;
      }
      
      $hook->setValues(array(
          'sendCC' => $email
      ));
       
      return true;

      In the FormIt call you call the returned sendCC value in the emailCC parameter.

      &emailCC=`[[+sendCC]]`
        Codeplaza Webdesign: for professional websites at low cost
      • discuss.answer
        • 53212
        • 4 Posts
        After searching for a bit longer and trying a few var_dumps I actually found out what was going on. The array containing the email properties actually isn't called options. It's called config. Thanks for the reply though.

        <?php
         
        $country = $hook->getValue('field1020');
         
        switch($country){
         
        case "France": 
         $hook->formit->[b]config[/b]['emailCC'] = '[email protected]';
        break;
         
        case "Netherlands":
         $hook->formit->[b]config[/b]['emailCC'] = '[email protected]';
        break;
        }
         
        return true;