How can i get dropdown values readable into email

cmn 18 May, 2009
Hi,

i have a dropdown box in my form and want to get the selected index human readable into the output mail:

<select naem="dd_color" size="1">
   <option value="1">red</option>
   <option value="2">green</option>
   <option value="3">blue</option>
</select>


with "human readable" i mean, i dont want to see the value eg "2", i want to see "green" instead.

i've googled a bit and found this forum topic: http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=5&t=14222

i guess he's doing quite the same, but when for some reason it doesnt work for me:

<?php

$arr_colors = array( '1'=>'red', '2'=>'green', '3'=>'blue' );
$MyForm =& CFChronoForm::getInstance('cf_1');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(2, 'color_readable', $arr_colors[$_POST['dd_color']]);

?>


i have two email templates. now i would expect {color_readable} would be parsed in the second email template. but it doesnt . is setEmailData the correct method at all?

would be nice if somebody could help me.

thx a lot, christian.
GreyHead 18 May, 2009
Hi christian,

My guess is that you need to save the code version in the database?

If so, set the Autogenerated Code to Run Before Email (note that this means it will not run unless Emails are enabled).

In the OnSubmit Before Box put this code:
<?php
$arr_colors = array( '1'=>'red', '2'=>'green', '3'=>'blue' );
$dd_color = JRequest::getInt('dd_color', '', 'post');
JRequest::setVar('dd_color', $arr_colors[$dd_color], 'post');
?>
NB Not tested and may need de-bugging!

Bob
cmn 18 May, 2009
Thank you, Bob!

that made it work.

Greets, Christian.
This topic is locked and no more replies can be posted.