We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36930
    • 22 Posts
    I am having troubles trying to use the checkboxes in a form to determine the recipient(s) of the email sent on submission. Best I can tell, it just doesn't work.
    - I can do it if I use radio buttons, but that limits it to just one recipient.
    - Does not work if i put the placeholder for either &emailTo or &emailCC
    - If i manually set emailTo, the email comes through with the correct email addresses passed to the placeholder in the body of the email.
    - Does not work if I select one checkbox or many
    - When I set the placeholder for emailTo, the email appears to fail to send. CC and BCC emails are not received.
    - Even if the email is not sent, formSave will still log the passed values, and the form successfully redirects
    - Using formit 2.2.0 and modx 2.3.2

    [[!FormIt?
    	&hooks=`spam,FormSave,email,redirect`
    	&emailTpl=`form-test-email`
    	&emailTo=`[[+hotels]]`
    	&emailCC=`[[*form-rfp-cc]]`
    	&emailSubject=`[[*form-rfp-subject]]`
    	&emailFrom=`website@[[++http_host]]`
    	&redirectTo=`8`
    	&fsFormTopic=`Meetings RFP Submission` 
    	&validate=`
    		contact-name:required,
    		contact-email:required`
    ]]
    


    <div class="form-third">
    					    			
    	<label for="contact_email">Hotels: <small>(All that apply)</small></label>
    		
    	<label class="check-label" for="hotel1">
    		<input type="checkbox" id="hotel1" name="hotels[]" value="[email protected]" />
    		DoubleTree
    	 </label>
    								        
    	<label class="check-label" for="hotel2">
    		<input type="checkbox" id="hotel2" name="hotels[]" value="[email protected]" />
    		Hyatt Lodge
    	</label>
    								        
    	<label class="check-label" for="hotel3">
    		 <input type="checkbox" id="hotel3" name="hotels[]" value="[email protected]" />
    		 Marriott
    	</label>
    								        
    	<label class="check-label" for="hotel4">
    		<input type="checkbox" id="hotel4" name="hotels[]" value="[email protected]" />
    		Residence Inn
    	</label>
    								        
    	<label class="check-label" for="hotel5">
    		<input type="checkbox" id="hotel5" name="hotels[]" value="[email protected]" />
    		Le Méridien
    	</label>
    					    			
    </div>
    
      • 19872
      • 1,078 Posts
      Maybe something like this would work?

      <label>Hotels:: [[!+fi.error.hotels]]</label>
      <input type="checkbox" name="hotels[]" value="[email protected]" [[!+fi.hotels:FormItIsChecked=`[email protected]`]] > DoubleTree
      <input type="checkbox" name="hotels[]" value="[email protected]" [[!+fi.hotels:FormItIsChecked=`[email protected]`]] > Hyatt Lodge
      <input type="checkbox" name="hotels[]" value="[email protected]" [[!+fi.hotels:FormItIsChecked=`[email protected]`]] > Mariott
      <input type="checkbox" name="hotels[]" value="[email protected]" [[!+fi.hotels:FormItIsChecked=`[email protected]`]] > Residence Inn
      <input type="checkbox" name="hotels[]" value="[email protected]" [[!+fi.hotels:FormItIsChecked=`[email protected]`]] > Le Méridien

      Probably have to adjust your styles if the goal was to have a stacked list instead on inline.

      I wonder though about email addresses needing to be comma separated. maybe each value should have a comma at the end?
      [ed. note: mmcgee last edited this post 11 years, 10 months ago.]
        • 10208 ☆ A M B ☆
        • 1,780 Posts
        Yes, that's the general idea Marc. Close! However in this case you can use a hook easily. Set the hook in the &emailTo parameter in formIt call, but don't use a new input for each. You'll use the <select name="emailTo"><option value="[email protected]"> [[!fi.emailTo:FormItIsSelected=`blah...]]name</option> for each instead.

        http://rtfm.modx.com/extras/revo/formit/formit.hooks/formit.hooks.email
        i.e.
        [[!FormIt?
           &emailTo=`[[+addressTo]]`
        ]]
        ...
        <select name="addressTo">
           <option value="[email protected]" [[!+fi.addressTo:FormItIsSelected=`[email protected]`]]>John</option>
           <option value="[email protected]" [[!+fi.addressTo:FormItIsSelected=`[email protected]`]]>Jane</option>
        </select>
          Frogabog- MODX Websites in Portland Oregon
          "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
          Having server issues? These guys have MODX Hosting perfected - SkyToaster
          • 36930
          • 22 Posts
          Thanks for both or your replies, but they don't quite address the issue I am having.

          - I do not need to require the checkbox input (so i don't need the FormItIsSelected filter)
          - Checkboxes are needed in order to populate multiple email addresses
          - The values of a checkbox selection are correct when passed via placholder into the body of the email.
          - The Issue, specificially, is when the placeholder are set as the "TO" or "CC"- it doesn't work there
            • 19872
            • 1,078 Posts
            Forms can be a real pickle

            http://rtfm.modx.com/extras/revo/formit/formit.tutorials-and-examples/formit.handling-selects,-checkboxes-and-radios

            Maybe a hook as Frogabog mentioned is needed. Perhaps formit treats or requires something different than perhaps if you were selecting a size or a color. email address vs. Blue
            Additionally, your are stringing multiple address into the placeholder. emails addresses would need to be comma separated.