Forums

Different Email Based on Radio Button Selection

Beyer 23 Mar, 2010
I have a form in which the Nominator of an award must select the type of award the Nominee is being nominated for. I would like a customized email to be sent to the Nominee that is based on the radio button selection. So, if my radio buttons are Award1 and Award2, if Award1 is selected, I would like an email to be sent to Nominee explaining he/she has been selected for Award1. Exact opposite if Award2 is selected.

Is this possible?

Thanks,
ClayB
GreyHead 23 Mar, 2010
Hi ClayB,

Please see FAQ #31, you'll find the basic code in there.

Bob
Beyer 23 Mar, 2010
Thank you, yes, I did see the FAQ. The FAQ is referring sending the email to a different EMAIL address upon radio selection. I want to send to the SAME email address but I want to send a different EMAIL TEMPLATE. Make sense?

I suppose the logic could be the same, but I don't fully understand the the variables in the PHP code being used. Here is my take...

I don't need the $emails_w array, since I already know that I am sending it to the same email address, so I assume I would make emails_2 a radio_2 (to select my radio button options)

<?php
/*$emails_2 = array('em1'=>'sample1@email.com', 'em2'=>'sample2@email.com', 'em3'=>'name_3@example.com', . . .);*/

$radio_2 = array('radio01'=>'/*select template 1*/', 'radio02'=>'/*select template 2*/', 'radio03'=>'/*select template 3*/', . . .);

$MyForm =& CFChronoForm::getInstance('form_name_here');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['recipients']]);
?> 


Is this about right? Can anyone flush this out any better?

Thanks,
ClayB
GreyHead 23 Mar, 2010
Hi Beyre,

Sorry I misunderstood (happens too often when there are a stack of posts to answer). We had another thread on enabling and disabling emails . . . please look at this post

Bob
Beyer 24 Mar, 2010
Hi Bob,

Thanks for the responses, but I am having some trouble understanding as it relates to my situation. Here is my form code:

<div class="form_item">
  <div class="form_element cf_radiobutton">
    <label class="cf_label" style="width: 200px;"></label>
    <div class="float_left">
      <input value="Intergovernmental Unity of Effort for Individual" title="Please Select an Award Category" class="radio validate-one-required" id="radio00" name="radio0" type="radio" />
      <label for="radio00" class="radio_label">Intergovernmental Unity of Effort for Individual</label>
      <br />
      
<input value="Intergovernmental Unity of Effort for Organization" title="Please Select an Award Category" class="radio validate-one-required" id="radio01" name="radio0" type="radio" />
      <label for="radio01" class="radio_label">Intergovernmental Unity of Effort for Organization</label>
      <br />
      
<input value="Community Leadership" title="Please Select an Award Category" class="radio validate-one-required" id="radio02" name="radio0" type="radio" />
      <label for="radio02" class="radio_label">Community Leadership</label>
      <br />
      
<input value="Volunteer" title="Please Select an Award Category" class="radio validate-one-required" id="radio03" name="radio0" type="radio" />
      <label for="radio03" class="radio_label">Volunteer</label>
      <br />
      

    </div>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_heading">
    <h3 class="cf_text">Enter Nominee Information Below</h3>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Nominee:</label>
    <input class="cf_inputbox required validate-alpha" maxlength="150" size="30" title="Please Enter A Name" id="text_3" name="nominee" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Title (Individual)</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_5" name="nomineeTitle" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Organization</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_6" name="nomineeOrganization" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Email Address</label>
    <input class="cf_inputbox required validate-email" maxlength="150" size="30" title="Please Enter A Valid Email Address" id="text_20" name="nomineeEmail" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Phone Number:</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="xxx-xxx-xxxx" id="text_7" name="nomineePhone" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Address</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="Please Enter an Address" id="text_9" name="nomineeAddress" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">City</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="Please Enter a City" id="text_10" name="nomineeCity" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">State</label>
    <select class="cf_inputbox validate-selection" id="select_11" size="1" title="Please Choose a State"  name="nomineeState">
    <option value="">Select A State</option>
      <option value="Alabama">Alabama</option>
<option value="Alaska">Alaska</option>
<option value="American Samoa">American Samoa</option>
<option value="Arizona">Arizona</option>
<option value="Arkansas">Arkansas</option>
<option value="California">California</option>
<option value="Colorado">Colorado</option>
<option value="Connecticut">Connecticut</option>
<option value="Delaware">Delaware</option>
<option value="District of Columbia">District of Columbia</option>
<option value="Florida">Florida</option>
<option value="Georgia">Georgia</option>
<option value="Guam">Guam</option>
<option value="Hawaii">Hawaii</option>
<option value="Idaho">Idaho</option>
<option value="Illinois">Illinois</option>
<option value="Indiana">Indiana</option>
<option value="Iowa">Iowa</option>
<option value="Kansas">Kansas</option>
<option value="Kentucky">Kentucky</option>
<option value="Louisiana">Louisiana</option>
<option value="Maine">Maine</option>
<option value="Maryland">Maryland</option>
<option value="Massachusetts">Massachusetts</option>
<option value="Michigan">Michigan</option>
<option value="Minnesota">Minnesota</option>
<option value="Mississippi">Mississippi</option>
<option value="Missouri">Missouri</option>
<option value="Montana">Montana</option>
<option value="Nebraska">Nebraska</option>
<option value="Nevada">Nevada</option>
<option value="New Hampshire">New Hampshire</option>
<option value="New Jersey">New Jersey</option>
<option value="New Mexico">New Mexico</option>
<option value="New York">New York</option>
<option value="North Carolina">North Carolina</option>
<option value="North Dakota">North Dakota</option>
<option value="Northern Marianas slands">Northern Marianas slands</option>
<option value="Ohio">Ohio</option>
<option value="Oklahoma">Oklahoma</option>
<option value="Oregon">Oregon</option>
<option value="Pennsylvania">Pennsylvania</option>
<option value="Puerto Rico">Puerto Rico</option>
<option value="Rhode Island">Rhode Island</option>
<option value="South Carolina">South Carolina</option>
<option value="South Dakota">South Dakota</option>
<option value="Tennessee">Tennessee</option>
<option value="Texas">Texas</option>
<option value="Utah">Utah</option>
<option value="Vermont">Vermont</option>
<option value="Virginia">Virginia</option>
<option value="Virgin Islands">Virgin Islands</option>
<option value="Washington">Washington</option>
<option value="West Virginia">West Virginia</option>
<option value="Wisconsin">Wisconsin</option>
<option value="Wyoming">Wyoming</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Zip Code</label>
    <input class="cf_inputbox required validate-number" maxlength="5" size="30" title="Please Enter a Zip Code" id="text_12" name="nomineeZip" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_heading">
    <h3 class="cf_text">Enter Nominator Information Below</h3>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Nominator</label>
    <input class="cf_inputbox required validate-alpha" maxlength="150" size="30" title="Please Enter a Name" id="text_11" name="nominator" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Title</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_12" name="nominatorTitle" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Organization</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_13" name="nominatorOrganization" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Email Address</label>
    <input class="cf_inputbox required validate-email" maxlength="150" size="30" title="Please Enter A Valid Email Address" id="text_21" name="nominatorEmail" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Phone Number</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="xxx-xxx-xxxx" id="text_15" name="nominatorPhone" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Address</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="Please Enter an Address" id="text_16" name="nominatorAddress" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">City</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="Please Enter a City" id="text_17" name="nominatorCity" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">State</label>
    <select class="cf_inputbox validate-selection" id="select_20" size="1" title="Please Select a State"  name="nominatorState">
    <option value="">Select A State</option>
      <option value="Alabama">Alabama</option>
<option value="Alaska">Alaska</option>
<option value="American Samoa">American Samoa</option>
<option value="Arizona">Arizona</option>
<option value="Arkansas">Arkansas</option>
<option value="California">California</option>
<option value="Colorado">Colorado</option>
<option value="Connecticut">Connecticut</option>
<option value="Delaware">Delaware</option>
<option value="District of Columbia">District of Columbia</option>
<option value="Florida">Florida</option>
<option value="Georgia">Georgia</option>
<option value="Guam">Guam</option>
<option value="Hawaii">Hawaii</option>
<option value="Idaho">Idaho</option>
<option value="Illinois">Illinois</option>
<option value="Indiana">Indiana</option>
<option value="Iowa">Iowa</option>
<option value="Kansas">Kansas</option>
<option value="Kentucky">Kentucky</option>
<option value="Louisiana">Louisiana</option>
<option value="Maine">Maine</option>
<option value="Maryland">Maryland</option>
<option value="Massachusetts">Massachusetts</option>
<option value="Michigan">Michigan</option>
<option value="Minnesota">Minnesota</option>
<option value="Mississippi">Mississippi</option>
<option value="Missouri">Missouri</option>
<option value="Montana">Montana</option>
<option value="Nebraska">Nebraska</option>
<option value="Nevada">Nevada</option>
<option value="New Hampshire">New Hampshire</option>
<option value="New Jersey">New Jersey</option>
<option value="New Mexico">New Mexico</option>
<option value="New York">New York</option>
<option value="North Carolina">North Carolina</option>
<option value="North Dakota">North Dakota</option>
<option value="Northern Marianas slands">Northern Marianas slands</option>
<option value="Ohio">Ohio</option>
<option value="Oklahoma">Oklahoma</option>
<option value="Oregon">Oregon</option>
<option value="Pennsylvania">Pennsylvania</option>
<option value="Puerto Rico">Puerto Rico</option>
<option value="Rhode Island">Rhode Island</option>
<option value="South Carolina">South Carolina</option>
<option value="South Dakota">South Dakota</option>
<option value="Tennessee">Tennessee</option>
<option value="Texas">Texas</option>
<option value="Utah">Utah</option>
<option value="Vermont">Vermont</option>
<option value="Virginia">Virginia</option>
<option value="Virgin Islands">Virgin Islands</option>
<option value="Washington">Washington</option>
<option value="West Virginia">West Virginia</option>
<option value="Wisconsin">Wisconsin</option>
<option value="Wyoming">Wyoming</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Zip Code</label>
    <input class="cf_inputbox required validate-number" maxlength="5" size="30" title="Please Enter a Zip Code" id="text_19" name="nominatorZip" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Submit Nominee Information" name="button_21" type="submit" /><input type="reset" name="reset" value="Reset"/>
  </div>
  <div class="cfclear"> </div>
</div>


And here is the code I put in the On Submit code - before sending email:

<?php
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$radio0 = JRequest::getString('radio0', '', 'post');
if ( $radio0 ) {
  $radio0 = explode(', ', $radio0);
  foreach ($radio0 as $v ) {
    $MyFormEmails->setEmailData($v, 'enabled', true);
  }
}
?>


The form submits, but I get a TON of errors. So, some comments and questions...

My award nomination form currently submits and sends 3 emails.

emailA - results to form owner
emailB - thank you to nominator
emailC - notification to nominee

Based on what I have read, I need the "split" email C into 4 different emails TEMPLATES (Do i need to create a new email for each template?) based on the radio button choice:
emailC1 - email for radio1
emailC2 - email for radio2
emailC3 - email for radio3
emailC4 - email for radio4

So, with that, how does the code to enable the emails work? Do all 6 emails need to be disabled (or just the 4) and then enable the 3 i need on each form submission? I am always going to need emailA and emailB and then some version of emailC (depending no radio button selection).

Uhg, I hope this isn't confusing, thanks again for any help.

ClayB
GreyHead 25 Mar, 2010
Hi ClayB,

When you say that you want to send a different email - is that fundamentally different - or is it just a phrase or two that changes.

1) If you want fundamentally different emails then you can either (a) add different setups + templates and switch between them; or (b) use a single template and add PHP* and a switch statement(s) to change the body text used depending on the radio button value.

If you use different templates then the way to do that is by enabling and disabling the Email Setups depending on the radio button value. The Email Setups are numbered - I think 1,2,3,4 . . . so that the value of $v in $MyFormEmails->setEmailData($v, 'enabled', true); needs to be a valid Email Setup number. At present your radio buttons return text strings in the values so you'd need extra code to convert from one to the other (or use the numbers as the radio button values).

2) If only a few phrases change then you can set those up as variables in the tempalte e.g. {award_title} and set the values of these in the OnSubmit Before box - again using a PHP switch statement:
<?php
$radio = JRequest::getString('radio0', '', 'post');
switch ($radio0):
  case 'xxx':
    JRequest::setVar('award_title', 'some text');
    . . .
    break;
  case 'yyy':
  default:
    JRequest::setVar('award_title', 'some other text');
    . . .
    break;
}
?>


Bob

* To use PHP in an Email template you have to turn off the HTML editor in the Email Setup Properties box.
tamarteleco 26 Apr, 2010
Hi GreyHead,

I did FAQ#31 but it appears not working.
I have a combobox of different departments (human resources, staff, etc) in the form. The user will choose one, and when he presses 'send' the on submit email should be sent the department...
The form is
<div class="form_item">
  <div class="form_element cf_text"> <span class="cf_text" style="font-weight:bold;font-size:1.3em;">Please fill in the following fields.</span> </div>
  
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" >Name:</label>
    <input class="cf_inputbox required" maxlength="300" size="25" title="Please, write your name." id="text_13" name="form_requestor" type="text" />
 
  </div>
  
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label">Department:</label>
    <select class="cf_inputbox validate-selection" id="select_1" size="1" title="Please, choose one option"  name="form_combo_department">
    <option value="">Select your department</option>
      <option value="Boards of Appeal">Boards of Appeal</option>
<option value="Cancellation and Litigation">Cancellation and Litigation</option>
<option value="Designs and Register">Designs and Register</option>
<option value="Department for IP Policy">Department for IP Policy</option>
<option value="Finance">Finance</option>
<option value="General Services">General Services</option>
<option value="Human Resources">Human Resources</option>
<option value="Information Technology">Information Technology</option>
<option value="Institutional Affairs and External Relations">Institutional Affairs and External Relations</option>
<option value="Internal Audit">Internal Audit</option>
<option value="Quality Management">Quality Management</option>
<option value="Trade marks">Trade marks</option>

    </select>
    <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">Department: :: Choose your department</div>
  </div>
  
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" >Business importance</label>
    <select class="cf_inputbox validate-selection" id="select_2" size="1" title="Please, choose one option"  name="form_combo_importance">
    <option value="">Select the importance</option>
      <option value="High">High</option>
<option value="Medium">Medium</option>
<option value="Low">Low</option>

    </select>
    <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">Business importance :: Choose the importance</div>
  </div>

</div>

<div class="form_item">
  <div class="form_element cf_textarea">
    <label class="cf_label" >Situation today without the improvement:</label>
    <textarea class="cf_inputbox" rows="2" id="text_4" title="Plese, write a small description" cols="38" name="form_text_improvement"></textarea>
    <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">Description of the improvement: :: Describe the current situation</div>
  </div>
  
</div>

<div class="form_item">
  <div class="form_element cf_textarea">
    <label class="cf_label" >Situation tomorrow with the improvement</label>
    <textarea class="cf_inputbox required" rows="2" id="text_5" title="Please, describe the future situation" cols="38" name="form_text_future_situation"></textarea>
    <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">:: Describe the future situation</div>
  </div>
  
</div>

<div class="form_item">
  <div class="form_element cf_textarea">
    <label class="cf_label" >Stakeholders/Departments/Users affected</label>
    <textarea class="cf_inputbox required" rows="2" id="text_6" title="Please, fill the text box" cols="38" name="form_text_affected"></textarea>
    <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">Stakeholders / Departments / Users affected :: Eg. IERD, QMD, QMS, ...</div>
  </div>

</div>

<div class="form_item">
  <div class="form_element cf_textarea">
    <label class="cf_label">Processes affected</label>
    <textarea class="cf_inputbox" rows="2" id="text_3" title="" cols="38" name="form_text_process_affected"></textarea>
    <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">Processes affected :: Eg. Manage Stakeholder relationships</div>
  </div>

</div>

<div class="form_item">
  <div class="form_element cf_textarea">
    <label class="cf_label" >IT tools affected</label>
    <textarea class="cf_inputbox" rows="2" id="text_11" title="" cols="38" name="form_text_tools_affected"></textarea>
    <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">IT tools affected :: Eg. Euromarc ++, Oppo Tool, etc...</div>
  </div>

</div>

<div class="form_item">
  <div class="form_element cf_fileupload">
    <label class="cf_label" >Supporting documentation</label>
    <input class="cf_fileinput cf_inputbox" title="" size="20" id="file_8" name="form_file_upload" type="file" />
    <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" alt="" src="components/com_chronocontact/css/images/tooltip.png"/></a>
				<div class="tooltipdiv">Supporting documentation :: Upload one file. doc,xls or zip format please</div>
  </div>
  </div>

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Send improvement idea" name="button_16" type="submit" />
  </div>

</div>




And the on submit:
<?php
$emails_2 = array(
'Cancellation and Litigation'=>'myemail@myemai.com',
'Designs and Register'=>'myemail@myemai.com', 
'Department for IP Policy'=>'myemail@myemai.com', 
'Finance'=>'myemail@myemai.com',
'General Services'=>'myemail@myemai.com',
'Human Resources'=>'myemail@myemai.com',
'Information Technology'=>'myemail@myemai.com',
'Institutional Affairs and External Relations'=>'myemail@myemai.com',
'Internal Audit'=>'myemail@myemai.com',
'Quality Management'=>'myemail@myemai.com',
'Trade marks'=>'myemail@myemai.com');
$MyForm =& CFChronoForm::getInstance('improvementidea_form');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['recipients']]);
?> 
<p style="text-align: center;color:black;padding-top:20px;padding-right:30px;padding-left:30px;"><img src="images/stories/icon_form.gif" border="0" alt="icon_form" width="47" height="46" /><span style="font-size: 14pt;color:black;"><strong> Your improvement idea has been sent to your Quality Officer who will progress it in line with the process card <a href="../qms/PC/process_card.php?process_card_id=17" target="_blank">C.00.03 Evaluate Improvement Idea.</a></strong></span></p>
<p style="text-align: center;color:black;padding-bottom:15px;"><span style="font-size: 14pt;color:black;"><strong>Thank you for your collaboration!</strong></span></p>
<div id="sent_form"><dl><dd> 
<table id="submit_form_im_idea" style="width: 504px; height: 297px;" border="0" cellspacing="5" cellpadding="5">
<tbody class="submit_improvement_idea">
<tr>
<td style="text-align: left;"><span style="font-weight: bold;">Users affected:</span></td>
<td><?php echo JRequest::getVar('form_text_affected', '', 'post'); ?></td>
</tr>
<tr style="text-align: left;">
<td style="text-align: left;"><span style="font-weight: bold;">Change requestor name:</span></td>
<td style="text-align: left;"><?php echo JRequest::getVar('form_requestor', '', 'post'); ?></td>
</tr>
<tr style="text-align: left;">
<td style="text-align: left;" valign="top"><span style="font-weight: bold;">Department:</span></td>
<td style="text-align: left;" valign="top"><?php echo JRequest::getVar('form_combo_department', '', 'post'); ?></td>
</tr>
<tr style="text-align: left;">
</tr>
<tr>
<td style="text-align: left;" valign="top"><span style="font-weight: bold;">Business importance:</span></td>
<td style="text-align: left;" valign="top"><?php echo JRequest::getVar('form_combo_importance', '', 'post'); ?></td>
</tr>
<tr style="text-align: left;">
<td style="text-align: left;" valign="top"><span style="font-weight: bold;">Description of the improvement:</span></td>
<td style="text-align: left;" valign="top"><?php echo JRequest::getVar('form_text_improvement', '', 'post'); ?></td>
</tr>
<tr style="text-align: left;">
<td style="text-align: left;" valign="top">
<p><span style="font-weight: bold;"><span style="font-weight: bold;">Stakeholders / Departments / </span></span></p>
<p><span style="font-weight: bold;">Users affected:</span></p>
</td>
<td style="text-align: left;" valign="top"><?php echo JRequest::getVar('form_text_affected', '', 'post'); ?></td>
</tr>
</tbody>
</table>
</dd></dl></div>
<div id="form_footer"><br /><dl><dd style="padding-left: 30px;"><strong>You can follow the status of your idea in the </strong><a href="index.php?option=com_wrapper&view=wrapper&Itemid=4">status overview</a> <strong>section</strong></dd></dl><dl><dd style="padding-left: 30px;"><br /></dd><dd style="padding-left: 30px;">«<a href="index.php?option=com_chronocontact&Itemid=5">Back to home</a></dd></dl></div>


Maybe is not working because the whitespaces of the combobox values??

Hope you see the problem.
Thanks!!!!
GreyHead 26 Apr, 2010
Hi tamarteleco,

The name of the select dropdown must match the value use use for $_POST in the OnSubmit code. Here they don't match, one is 'form_combo_department' the other is 'recipients'.

Bob
tamarteleco 26 Apr, 2010
Thanks Bob,

I've change it, but I still don't receive any e-mail. It works fine when I remove the code:

<?php
$emails_2 = array(
'Cancellation and Litigation'=>'mail@mail',
'Designs and Register'=>'mail@mail', 
'Department for IP Policy'=>'mail@mail', 
'Finance'=>'mail@mail',
'General Services'=>'mail@mail',
'Human Resources'=>'mail@mail',
'Information Technology'=>'mail@mail',
'Institutional Affairs and External Relations'=>'mail@mail',
'Internal Audit'=>'mail@mail',
'Quality Management'=>'mail@mail',
'Trade marks'=>'mail@mail');
$MyForm =& CFChronoForm::getInstance('improvementidea_form');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['form_combo_department']]);
?> 


Does it have any conflict with other part, like email templates? I don't receive any error, so I don't know how to continue...

the full code of "on Sumbit code -before sending email:"
<?php
$emails_2 = array(
'Cancellation and Litigation'=>'mail@mail',
'Designs and Register'=>'mail@mail', 
'Department for IP Policy'=>'mail@mail', 
'Finance'=>'mail@mail',
'General Services'=>'mail@mail',
'Human Resources'=>'mail@mail',
'Information Technology'=>'mail@mail',
'Institutional Affairs and External Relations'=>'mail@mail',
'Internal Audit'=>'mail@mail',
'Quality Management'=>'mail@mail',
'Trade marks'=>'mail@mail');
$MyForm =& CFChronoForm::getInstance('improvementidea_form');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['form_combo_department']]);
?> 
<p style="text-align: center;color:black;padding-top:20px;padding-right:30px;padding-left:30px;"><img src="images/stories/icon_form.gif" border="0" alt="icon_form" width="47" height="46" /><span style="font-size: 14pt;color:black;"><strong> Your improvement idea has been sent to your Quality Officer who will progress it in line with the process card <a href="../qms/PC/process_card.php?process_card_id=17" target="_blank">C.00.03 Evaluate Improvement Idea.</a></strong></span></p>
<p style="text-align: center;color:black;padding-bottom:15px;"><span style="font-size: 14pt;color:black;"><strong>Thank you for your collaboration!</strong></span></p>
<div id="sent_form"><dl><dd> 
<table id="submit_form_im_idea" style="width: 504px; height: 297px;" border="0" cellspacing="5" cellpadding="5">
<tbody class="submit_improvement_idea">
<tr>
<td style="text-align: left;"><span style="font-weight: bold;">Users affected:</span></td>
<td><?php echo JRequest::getVar('form_text_affected', '', 'post'); ?></td>
</tr>
<tr style="text-align: left;">
<td style="text-align: left;"><span style="font-weight: bold;">Change requestor name:</span></td>
<td style="text-align: left;"><?php echo JRequest::getVar('form_requestor', '', 'post'); ?></td>
</tr>
<tr style="text-align: left;">
<td style="text-align: left;" valign="top"><span style="font-weight: bold;">Department:</span></td>
<td style="text-align: left;" valign="top"><?php echo JRequest::getVar('form_combo_department', '', 'post'); ?></td>
</tr>
<tr style="text-align: left;">
</tr>
<tr>
<td style="text-align: left;" valign="top"><span style="font-weight: bold;">Business importance:</span></td>
<td style="text-align: left;" valign="top"><?php echo JRequest::getVar('form_combo_importance', '', 'post'); ?></td>
</tr>
<tr style="text-align: left;">
<td style="text-align: left;" valign="top"><span style="font-weight: bold;">Description of the improvement:</span></td>
<td style="text-align: left;" valign="top"><?php echo JRequest::getVar('form_text_improvement', '', 'post'); ?></td>
</tr>
<tr style="text-align: left;">
<td style="text-align: left;" valign="top">
<p><span style="font-weight: bold;"><span style="font-weight: bold;">Stakeholders / Departments / </span></span></p>
<p><span style="font-weight: bold;">Users affected:</span></p>
</td>
<td style="text-align: left;" valign="top"><?php echo JRequest::getVar('form_text_affected', '', 'post'); ?></td>
</tr>
</tbody>
</table>
</dd></dl></div>
<div id="form_footer"><br /><dl><dd style="padding-left: 30px;"><strong>You can follow the status of your idea in the </strong><a href="index.php?option=com_wrapper&view=wrapper&Itemid=4">status overview</a> <strong>section</strong></dd></dl><dl><dd style="padding-left: 30px;"><br /></dd><dd style="padding-left: 30px;">«<a href="index.php?option=com_chronocontact&Itemid=5">Back to home</a></dd></dl></div>


Thanks!!!

T.
tamarteleco 27 Apr, 2010
Hi Bob,

Do you know how can I move forward with this issue? Or another working solution?
The form sends an email correctly when the code is without the $emails_2 = array... part,
but it stops sending emails when I add this part.

Hope you could help.

Thanks again.

T.
GreyHead 27 Apr, 2010
Hi tamarteleco,

This solution works - you just have to debug your code.

What do you see if you turn Form Debug on and submit the form?

Bob
tamarteleco 27 Apr, 2010
Hi Bob,

Thanks for your tip!
I swith the debug on and it appears the "To" field empty as follows:
[code] 1. Form passed first SPAM check OK
2. Form passed the submissions limit (if enabled) OK
3. Form passed the Image verification (if enabled) OK
4. Form passed the server side validation (if enabled) OK
5. $_POST Array: Array ( [form_requestor] => Tamar [form_combo_department] => Boards of Appeal [form_combo_importance] => High [form_text_improvement] => adkljf [form_text_future_situation] => kljñkl [form_text_affected] => kljlñk [form_text_process_affected] => kljñl [form_text_tools_affected] => kljlñk [button_16] => Send improvement idea [d4513f6e1bd4126c90f8577fcca05523] => 1 [1cf1] => 17c3e6fe0aad092225a6796592af43d1 [chronoformname] => improvementidea_form )
6. $_FILES Array: Array ( [form_file_upload] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) )
7. Form passed the plugins step (if enabled) OK
8. An email has been SENT successfully from (My_name)myemil@myemail... to
9. Debug End[/code]

It gives error 4, and size 0 because I didn't attach a file. But attaching a file it continues having the "To" field empty...

Thanks again.

T.
tamarteleco 28 Apr, 2010
Hi Bob,

Do you know how I can debug deeper to know where the recipients emails are lost?
I can't find why the "To" field is empty.

Thanks.
T.
tamarteleco 03 May, 2010
Hi Bob,

Any Idea on how I could find the reason why Chrono doesn't send the emails?
The last thing I could see was that the field "to" is empty when I add the code to send different emails based on the choise of the combo box.

Hope you have any idea.
Thanks.
GreyHead 06 May, 2010
Hi tamarteleco,

The example you posted last will fail becasue 'Boards of Appeal' isn't in the list of emails you have set up. Best to have a default settign to catch those.

Bob
tamarteleco 25 May, 2010
Thanks Bob,

Now I'm having better responses with the server, I see that the email is send to the address in the debug window. I'm testing it, but it seems It will work fine!.

I would like to ask you, if it is possible with Chronoengine to keep the typed data entered in the form?

I've the problem that when the users try to upload a file that is not supported, an error message appears displaying that those extension is not allowed BUT all the data typed in the form is lost. And the get angry to type everything again.

I was looking in the forum but I didn't find sth related.

Hope you can help me.

Thanks.
GreyHead 26 May, 2010
Hi tamartelco,

On the form General Tab set "Republish fields if error occured" to 'Try to republish'.

Bob
tamarteleco 31 May, 2010
Hi Bob,

Can I put more than one email per item choosen in the combobox?

<?php
$emails_2 = array(
'combo1'=>'email1',
'combo2=>'email2',
....etc);
$MyForm =& CFChronoForm::getInstance('improvementidea_form');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['form_combo_department']]); 
?> 


Will this work if I put :

'combo1'=>'email1,email2,email3'...etc



??

I have to do that if the user choose 'combo1' for example, the mail is sent to 3 recipients, for the rest will be only one.

I don't know if I have explain, correctly...

Thanks!
GreyHead 31 May, 2010
Hi Tamartelco,

Yes I think so
'combo2=>'user1@example.com,user2@example.com',

Bob
This topic is locked and no more replies can be posted.