<h2>Email</h2> [[!Profile? &prefix=`usr.`]] [[!FormIt? &hooks=`emailSelector,email,redirect` &emailTpl=`bar.email` &emailSubject=`Inquiry` &emailTo=`[[+emailAddresses]]` &emailCC=`[[+usr.email]]` &emailBCC=`` &emailFromName=`[[+usr.username]]` &redirectTo=`72` &validate=`text:required:stripTags` ]] <form action="[[~[[*id]]]]" method="post" class="nice"> <input type="hidden" name="nospam:blank" value="" /> <p> <label>Choose whom to email: [[!+fi.error.whom]]</label> <input type="hidden" name="whom[]" value="" /> <input type="radio" name="whom[]" value="0" [[!+fi.color:FormItIsChecked=`1`]] > First Person <input type="radio" name="whom[]" value="1" [[!+fi.color:FormItIsChecked=`2`]] > Second Person <input type="radio" name="whom[]" value="2" [[!+fi.color:FormItIsChecked=`3`]] > Both People </p>
<?php $group[0] = 't@barcom'; // First Person $group[1] = '[email protected]'; // Second Person $group[2] = '[email protected], [email protected]'; // Both People $userChoice = $hook->getValue('whom'); $hook->setValue('emailAddresses',$group[$userChoice]); return true;
[2012-03-13 16:04:10] (ERROR @ /[path snipped out]/core/cache/includes/elements/modsnippet/38.include.cache.php : 11) PHP warning: Illegal offset type
This question has been answered by TomMLS. See the first response.
<input type="radio" name="whom[]" value="0" [[!+fi.whom:FormItIsChecked=`1`]] >
<input type="radio" name="whom[]" value="0" [[!+fi.color:FormItIsChecked=`1`]] >
<?php $group[0] = 't@barcom'; // First Person $group[1] = '[email protected]'; // Second Person $group[2] = '[email protected], [email protected]'; // Both People $userChoice = $hook->getValue('whom'); $modx->log(modX::LOG_LEVEL_ERROR, 'userchoice :'.$userChoice ); // output the value of userchoice in your error log (just to be sure there is a value) you can remove this line once you have it to work $choice = intval($userChoice); // convert string in integer $hook->setValue('emailAddresses',$group[$choice]); return true;
<input type="radio" name="whom" value="2" [[!+fi.whom:FormItIsChecked=`3`]] > Both People
<p> <label>Choose whom to email: [[!+fi.error.whom]]</label> <input type="hidden" name="whom" value="" /> <input type="radio" name="whom" value="0" [[!+fi.whom:FormItIsChecked=`1`]] > First Person <input type="radio" name="whom" value="1" [[!+fi.whom:FormItIsChecked=`2`]] > Second Person <input type="radio" name="whom" value="2" [[!+fi.whom:FormItIsChecked=`3`]] > Both People </p>
<?php $group[0] = 't@barcom'; // First Person $group[1] = '[email protected]'; // Second Person $group[2] = '[email protected], [email protected]'; // Both People $userChoice = $hook->getValue('whom'); $modx->log(modX::LOG_LEVEL_ERROR, 'userchoice :'.$userChoice ); // output the value of userchoice in your error log (just to be sure there is a value) you can remove this line once you have it to work $choice = intval($userChoice); // convert string in integer $hook->setValue('emailAddresses',$group[$choice]); return true;
// &hooks=`emailSelectorCustom, // &emailTo=`[[+emailAddresses]]` // $stateChoice = "NE"; $stateChoice = $hook->getValue('state'); $eastCoast = array("NE","NY","FL"); // $modx->log(modX::LOG_LEVEL_ERROR, 'userchoice :'.$userChoice ); //remove this line once you have it working if (in_array($stateChoice, $eastCoast)) { // East Coast Email $hook->setValue('emailAddresses', '[email protected]'); } else { // West Coast Email // default this email address if nothing is matched above $hook->setValue('emailAddresses', '[email protected]'); } return true;