Email to eval not working

ddesigns

New Member
I have a simple dropdown menu in my form with a case switch to select the appropriate email address to send the submission to. I took this directly from the plugin docs. The email is sent with no problems using the normal email methods. Just seems to be when using the eval php.

email to eval code:
Code:
$contact = $this->data['contact___reason_for_contact'];
    switch ($contact) {
    case 'general':
        $email = 'tim@addy1.com';
        break;
    case 'booking':
        $email = 'tim@addy2.com';
        break;
    case 'catering':
        $email = 'tim@addy3.com';
        break;
}
return $email;
echo $email;
 
Try dumping $contact to see what it is set to, so second line (after setting $contact before the case), do ...

Code:
var_dump($contact);exit;

... and submit the form again. It's possible the value may be an array not a string.

-- hugh
 
Thanks that cleared things up a bit. It appears that contact___reason_for_contact is reading the label of the select element and not the value. Changing my case switches to the label seemed to work. Not sure if this is a bug, may want to look into that.
 
If you append _raw to the element name you should get the value. Any element that has a concept of value and label (dropdowns, joins, etc), the element name gets you the label, appending _raw to the element name gets you the value.

-- hugh
 
Hi, i have the same problem.
Dumping $contact (appending _raw to the element name) show me this:
Code:
array(1) { [0]=> string(11) "laboratorio" }
so, in my case the value is an array.
 
Yup, elements which use the elementlist.php model (joins, dropdowns, etc) will be arrays in our internal data structures, as they can potentially have multiple values.

-- hugh
 
Back
Top