We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43092
    • 11 Posts
    Hi there,

    I am trying to use two different formit froms on the same page. The problem is that when I submit one form, the other one also gets sumbitted.

    Is there any way to submit only a single form from the same page?

    Form #1:
    --------
    [[!FormIt? &hooks=`spam,email,lg.txtlocal,redirect` 
               &emailTpl=`request-callback-email-template` 
    		   &emailSubject=`Callback Request` 
    		   &emailTo=`[email protected]`
    ]]
    
    
    <form class="lg.callback.form" id="lg.callback.form" action="[[~[[*id]]]]" method="post">
    	<input type="hidden" name="nospam:blank" value=""/>
    	<label for="name"> Name: <span class="error">[[!+fi.error.name]]</span></label>
    	<input id="name" type="text" name="name" value="[[!+fi.name]]" class="name" />
    	<label for="phone"> Phone: <span class="error">[[!+fi.error.phone]]</span></label>
    	<input id="phone" type="text" name="phone" value="[[!+fi.phone]]" class="phone"/>
    
    	<input type="submit" value="Request a call back"/>
    
    </form>
    <script>


    Form #2:
    --------
    [[!FormIt? &hooks=`hook_msSaveForm,redirect`
    		   &redirectTo=`[[*id]]`
    		   &redirectParams=`{"action":"submitOrder"}`
    		   &placeholderPrefix=``
    		   &customValidators=`lg.phone_invalid`
    		   &validate=`receiver:required, 
    					  phone:required:lg.phone_invalid, 
    					  email:required:email, 
    					  comment:stripTags`
    ]]
    
    <form id="addrForm" method="post" action="[[~[[*id]]]]" class="center" data-target="#addrForm">
    	<input type="hidden" name="nospam:blank" value=""/>
    
    	<label for="receiver"> Name: <span class="error">[[+error.receiver]]</span></label><br class="clear"/>
    	<input id="receiver" type="text" name="receiver" value="[[+receiver]]" class="required" /><br class="clear"/>
    
    	<label for="phone"> Phone: <span class="error">[[!+error.phone]]</span></label><br class="clear"/>
    	<input id="phone" type="text" name="phone" value="[[!+phone]]"/><br class="clear"/>
    
    	<label for="email">E-Mail:  <span class="error">[[!+error.email]]</span> </label><br class="clear"/>
    	<input id="email" type="text" name="email" class="required email" value="[[!+email]]" /><br class="clear"/>
    
    	<label for="comment">Additional details: <span class="error">[[!+error.comment]]</span></label><br class="clear"/>
    	<textarea id="comment" name="comment" rows="7">[[!+comment]]</textarea><br class="clear"/>
    
    	<div class="form-buttons">
    		<input type="submit" class="btn btn-primary" value="Submit Inquiry">
    	</div>
    	<div class="form-buttons">
    		<div class="line number1 index0 alt2"></div>
    	</div>
    </form>
    


    Many thanks, Luke
      • 44234
      • 219 Posts
      You need to use the &submitVar parameter in your call:
      &submitVar=`foo`

      and amend the submit button to include:
      <input type="submit" name="foo" class="btn btn-primary" value="Submit Inquiry">
        Find me on Twitter, GitHub or Google+
        • 21078
        • 77 Posts
        Hi!

        Yes, just use the &submitVar parameter with your FormIt calls:

        [[!FormIt? ... &submitVar=`myform1`]]
         
         
        <form ...>
            ...
            <input type="submit" value="Request a call back" name="myform1" />
        </form>
        
          L.net Web Solutions
          Professional webdesign and development with MODX and WordPress.
          • 43092
          • 11 Posts
          Thank you. It does the trick.

          Luke