We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4429
    • 429 Posts
    I’m trying to build a simple contact form.

    I need the following fields:

    • Name
      Email address
      Regarding
      Message

    Now depending on the what the email is regarding I need it to go to different addresses.

    I have the following template and calls:

    <p class="error">[+validationmessage+]</p>
    
    <form method="post" action="[~[*id*]~]" id="EmailForm" name="EmailForm">
    
    	<fieldset>
    
    		<input name="formid" type="hidden" value="ContactForm" />
    
    		<label for="cfName">Your name:
    		<input name="name" id="cfName" class="text" type="text" eform="Your Name::1:" /> </label>
    
    		<label for="cfEmail">Your Email Address:
    		<input name="email" id="cfEmail" class="text" type="text" eform="Email Address:email:1" /> </label>
    
    		
    <select name="nature" eform="Nature of enquiry:listbox:1">
          <option value="1">General enquiries</option>
           <option value="2">Advertising enquiries </option>
          <option value=""3">Media and PR enquiries</option>
          <option value=""4">Technical enquiries</option>
    </select>
    
    		
    
    <!--
    		<select name="subject" id="cfRegarding" eform="Form Subject::1">
    			<option value="General Inquiries">General Enquiries</option>
    			<option value="Press">Bulk Sales</option>
    			<option value="Press">Returns</option>
    			<option value="Press">Press or Interview Request</option>
    			<option value="Partnering">Partnering Opportunities</option>
    		</select>
    -->
    		<label for="cfMessage">Message: 
    		<textarea name="message" id="cfMessage" rows="4" cols="20" eform="Message:textarea:1"></textarea>
    		</label>
    <!--
    <p>
    Please enter the anti spam code below:<br />
    <img src="[+verimageurl+]" alt="verification code" border="1"/>
    </p>
    <p></p>
    <p>
    <label accesskey="c" for="vericode">code</label>
    <input type="text" name="vericode" size="20" />
    </p>
    -->
    		<label> </label><input type="submit" name="contact" id="cfContact" class="button" value="Send This Message" />
    
    	</fieldset>
    
    </form>
    



    [!eForm? &formid=`ContactForm` &subject=`[+subject+]` &to=`[email protected],[email protected],[email protected],[email protected]` &ccsender=`1` &tpl=`ContactForm` &report=`ContactFormReport` &invalidClass=`invalidValue` &requiredClass=`requiredValue` &cssStyle=`ContactStyles` add &vericode=`0` &gotoid=`65` &mailselector=`nature` !] 


    Eform complains that the subject is invalid.

    I want the ’regarding’ bit to also work as the subject as well as telling eform where to send the email.


      • 33337
      • 3,975 Posts
      change
      eform="Nature of enquiry:listbox:1
      to
      eform="Nature of enquiry::1
        Zaigham R - MODX Professional | Skype | Email | Twitter

        Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • 4429
        • 429 Posts
        Just tired that and i get the following:

        Some errors were detected in your form:
        The following required field(s) are missing: Nature of enquiry
        Form Subject » Incorrect value
          • 33337
          • 3,975 Posts
          I think you need to add empty value in the options as well. eg.
          <option></option>
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link
            • 4429
            • 429 Posts
            Still the same. here is my form template:

            <p class="error">[+validationmessage+]</p>
            
            <form method="post" action="[~[*id*]~]" id="EmailForm" name="EmailForm">
            
            	<fieldset>
            
            		<input name="formid" type="hidden" value="ContactForm" />
            
            		<label for="cfName">Your name:
            		<input name="name" id="cfName" class="text" type="text" eform="Your Name::1:" /> </label>
            
            		<label for="cfEmail">Your Email Address:
            		<input name="email" id="cfEmail" class="text" type="text" eform="Email Address:email:1" /> </label>
            
            		
            <select name="nature" eform="Nature of enquiry::1">
            <option> </option>
                  <option value="1">General enquiries</option>
                   <option value="2">Advertising enquiries </option>
                  <option value=""3">Media and PR enquiries</option>
                  <option value=""4">Technical enquiries</option>
            </select>
            
            		<label for="cfRegarding">Subject Title
            		<input name="subject" id="cfRegarding"  class="text" type="text" eform="Form Subject::1"/> <label>
            
            
            <!--
            		<select name="subject" id="cfRegarding" eform="Form Subject::1">
            			<option value="General Inquiries">General Enquiries</option>
            			<option value="Press">Press or Interview Request</option>
            			<option value="Partnering">Partnering Opportunities</option>
            		</select>
            -->
            		<label for="cfMessage">Message: 
            		<textarea name="message" id="cfMessage" rows="4" cols="20" eform="Message:textarea:1"></textarea>
            		</label>
            <!--
            <p>
            Please enter the anti spam code below:<br />
            <img src="[+verimageurl+]" alt="verification code" border="1"/>
            </p>
            <p></p>
            <p>
            <label accesskey="c" for="vericode">code</label>
            <input type="text" name="vericode" size="20" />
            </p>
            -->
            		<label> </label><input type="submit" name="contact" id="cfContact" class="button" value="Send This Message" />
            
            	</fieldset>
            
            </form>
            
              • 16278
              • 928 Posts
              If you’re using PHx, you’ll need to make the parameter &subject=`((subject))` rather than &subject=`[+subject+]` to avoid a clash.
              smiley KP
                • 29626
                • 34 Posts
                These section is buggy because of extra double quotes in options with values 3 and 4...

                		
                <select name="nature" eform="Nature of enquiry::1">
                <option> </option>
                      <option value="1">General enquiries</option>
                       <option value="2">Advertising enquiries </option>
                      <option value=""3">Media and PR enquiries</option>
                      <option value=""4">Technical enquiries</option>
                </select>
                


                You could use a program editor with syntax colouring (which could highlight some typing errors).
                PsPad (when you choose a given filetype), EMacs or Vim are enough powerfull to evict these errors most of the next times.


                I see you have found the HTML piece of code to add a captcha code to eForm.

                Cheers.
                Terry.
                  • 4429
                  • 429 Posts
                  fixed those errors. They were very hard to spot on a 2048x1500 monitor.

                  I also tired ((subject)) rather than [+subject+] - neither worked though


                  Some errors were detected in your form:
                  Form Subject » Incorrect value


                  I presume its to do with this line?

                  <label for="cfRegarding">Subject Title
                  		<input name="subject" id="cfRegarding"  class="text" type="text" eform="Form Subject::1"/> <label>
                    • 29626
                    • 34 Posts
                    The problem is you have not specified the type of these textfield.
                    When you work with select html tags, you could set the field to accept multiple options types.
                    But I think it is not the case when you are working with simple input tags. The type is mandatory there.

                    So change:
                     eform="Form Subject::1"


                    to:
                     eform="Form Subject:string:1"
                    because it’s a textfield.
                      • 4429
                      • 429 Posts
                      <label for="cfRegarding">Subject Title
                      		<input name="subject" id="cfRegarding"  class="text" type="text"  eform="Form Subject:string:1"/> </label>



                      Same issue still. I’ve only used the standard eform before and the documentation in the wiki is limited. I’m not sure of the issue here. Of course I could turn validation off if necessary