We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50574
    • 70 Posts
    Hello all

    I have three forms on one page that I'm struggling to get to work. The good news is that all three forms submit data using FormItSaveForm. Then one sends an email using 'email' hook but doesn't seem to send using FormItAutoResponder (although this might be a spam issue – I'm still testing) but doesn't redirect. Another does the same as above but does redirect and the third redirects but doesn't send any emails.

    All the forms are shown and hidden by clicking on JS tabs but are essentially on the same page. Originally the data submitted fine (although sending to the user-inputted email seemed to be intermittent) but there was a problem that if an error was fired in the second or third forms it was also show as an error in the one or two forms before it. So I included &submitVar with unique names for the submit button and this is where I'm up to.

    I've slightly altered out some of the info in the following code for confidentiality reasons but I'd be happy to show someone the actual dev site via PM if it'd help.

    Form one
    <div class="container">
        [[!FormIt? 
        &hooks=`email,FormItAutoResponder,redirect,FormItSaveForm`
        &submitVar=`submit-general`
        &emailFrom=`[email protected]` 
        &emailTpl=`AdminGeneralEnquiryEmail`
        &emailTo=`[email protected]`
        &emailSubject=`What admin will see`
        &fiarTpl=`generalEnquiryEmail`
        &fiarSubject=`What the customer will see`
        &fiarToField=`email-happy`
        &fiarFrom=`[email protected]`
        &redirectTo=`168`
        &formName=`generalEnquiry`
        &formFields=`name, email, message, marketing, third-marketing, site-use`
        &validate=`name:required, email:email:required, message:required:stripTags`]]  
        <div class="well marginTop25">
            <form action="[[~[[*id]]]]" method="post" id="generalForm">
                <div class="formRow">
                    <label for="name">Name* [[!+fi.error.name:notempty=`<span class="label label-important">This is a required field.</span>`]]</label>
                </div>
                <div class="formRow [[!+fi.error.name:notempty=`control-group error`]]" id="name">
                    <input type="text" name="name" value="[[!+fi.name]]" class="input-block-level">
                </div>
                <div class="formRow">
                    <label for="email">Email* [[!+fi.error.email:notempty=`<span class="label label-important">This is a required field.</span>`]]</label>
                </div>
                <div class="formRow [[!+fi.error.email:notempty=`control-group error`]]" id="email">
                    <input type="text" name="email" value="[[!+fi.email]]" class="input-block-level">
                </div>
                <div class="formRow">
                    <label for="message">Message* [[!+fi.error.message:notempty=`<span class="label label-important">This is a required field.</span>`]]</label>
                </div>
                <div class="formRow [[!+fi.error.message:notempty=`control-group error`]]" id="message">
                    <textarea name="message" cols="30" rows="10" value="[[!+fi.message]]" class="input-block-level"></textarea>
                </div>
                <div class="formRow">
                    <input type="submit" value="Submit" name="submit-general" class="btn btn-primary">
                    <div class="clear"></div>
                </div>
                <div class="formRow">
                    <p>
                    <input type="checkbox" name="marketing[]" value="marketing" [[!+fi.marketing:FormItIsChecked=`marketing`]] checked > 
                    <label class="note">I AM HAPPY TO RECEIVE UPDATES ABOUT PRODUCTS</label>
                    </p>
                    <p>
                    <input type="checkbox" name="third-marketing[]" value="third-marketing" [[!+fi.third-marketing:FormItIsChecked=`third-marketing`]] >
                    <label class="note">I AM HAPPY TO RECEIVE UPDATES FROM THIRD PARTIES</label>
                    </p>
                    <p>
                    <input type="checkbox" name="site-use[]" value="site-use" [[!+fi.site-use:FormItIsChecked=`site-use`]] checked >
                    <label class="note">I AM HAPPY FOR MY COMMENTS TO BE USED ON THE WEBSITE</label>
                    </p>
                </div>
            </form>
        </div>
    </div>
    

    Form two
    <div class="container">
        [[!FormIt? 
        &hooks=`email,FormItAutoResponder,redirect,FormItSaveForm`
        &submitVar=`submit-happy`
        &emailFrom=`[email protected]` 
        &emailTpl=`adminHappyEnquiryEmail`
        &emailTo=`[email protected]`
        &emailSubject=`What Admin will see`
        &fiarTpl=`happyEnquiryEmail`
        &fiarSubject=`What the customer will see`
        &fiarToField=`email-happy`
        &fiarFrom=`[email protected]`
        &redirectTo=`168`
        &formName=`happyEnquiry`
        &formFields=`name-happy, email-happy, message-happy, marketing-happy, third-marketing-happy, site-use-happy`
        &fieldNames=`name-happy==name, email-happy==email, message-happy==message,marketing-happy==marketing, third-marketing-happy==third party marketing, site-use-happy==site use`
        &validate=`name-happy:required, email-happy:email-happy:required, message-happy:required:stripTags` 
        ]]  
        <div class="well marginTop25">
            <form action="[[~[[*id]]]]" method="post" id="happyForm">
                <div class="formRow">
                    <label for="name-happy">Name* [[!+fi.error.name-happy:notempty=`<span class="label label-important">This is a required field.</span>`]]</label>
                </div>
                <div class="formRow [[!+fi.error.name-happy:notempty=`control-group error`]]" id="name-happy">
                    <input type="text" name="name-happy" value="[[!+fi.name-happy]]" class="input-block-level">
                </div>
                <div class="formRow">
                    <label for="email-happy">Email* [[!+fi.error.email-happy:notempty=`<span class="label label-important">This is a required field.</span>`]]</label>
                </div>
                <div class="formRow [[!+fi.error.email-happy:notempty=`control-group error`]]" id="email-happy">
                    <input type="text" name="email-happy" value="[[!+fi.email-happy]]" class="input-block-level">
                </div>
                <div class="formRow">
                    <label for="message-happy">Message* [[!+fi.error.message-happy:notempty=`<span class="label label-important">This is a required field.</span>`]]</label>
                </div>
                <div class="formRow [[!+fi.error.message-happy:notempty=`control-group error`]]" id="message-happy">
                    <textarea name="message-happy" cols="30" rows="10" value="[[!+fi.message-happy]]" class="input-block-level"></textarea>
                </div>
                <div class="formRow">
                    <input type="submit" value="Submit" name="submit-happy" class="btn btn-primary">
                    <div class="clear"></div>
                </div>
                <div class="formRow">
                    <p>
                    <input type="checkbox" name="marketing-happy[]" value="yes" [[!+fi.marketing-happy:FormItIsChecked=`marketing-happy`]] checked > 
                    <label class="note">I AM HAPPY TO RECEIVE UPDATES ABOUT PRODUCTS</label>
                    </p>
                    <p>
                    <input type="checkbox" name="third-marketing-happy[]" value="yes" [[!+fi.third-marketing-happy:FormItIsChecked=`third-marketing-happy`]] >
                    <label class="note">I AM HAPPY TO RECEIVE UPDATES FROM THIRD PARTIES</label>
                    </p>
                    <p>
                    <input type="checkbox" name="site-use-happy[]" value="yes" [[!+fi.site-use-happy:FormItIsChecked=`site-use-happy`]] checked >
                    <label class="note">I AM HAPPY FOR MY COMMENTS TO BE USED ON THE WEBSITE</label>
                    </p>
                </div>
            </form>
        </div>
    </div>

    Form three
    <div class="container">
        [[!FormIt? 
        &hooks=`email,FormItAutoResponder,redirect,FormItSaveForm`
        &submitVar=`submit-unhappy`
        &emailFrom=`[email protected]` 
        &emailTpl=`adminUnhappyEnquiryEmail`
        &emailTo=`[email protected]`
        &emailSubject=`What admin will see`
        &fiarTpl=`unhappyEnquiryEmail`
        &fiarSubject=`What the customer will see`
        &fiarToField=`email-unhappy`
        &fiarFrom=`[email protected]`
        &redirectTo=`171`
        &store=`1`
        &formName=`unhappyEnquiry`
        &formFields=`refnum, name-unhappy, email-unhappy, batch-unhappy, product-unhappy, supermarket-unhappy, supermarket-location-unhappy, address-unhappy, marketing-unhappy, third-marketing-unhappy, site-use-unhappy`
        &fieldNames=`name-unhappy==name, email-unhappy==email, batch-unhappy==batch code, product-unhappy==product, supermarket-unhappy==supermarket, supermarket-location-unhappy==supermarket-location, address-unhappy==address, marketing-unhappy==marketing, third-marketing-unhappy==third party marketing, site-use-unhappy==site use`
        &validate=`name-unhappy:required, email-unhappy:email-unhappy:required, address-unhappy:required, message-unhappy:required:stripTags` 
        ]]  
        <div class="well marginTop25">
            <form action="[[~[[*id]]]]" method="post" id="unahppyForm">
                <input type="hidden" name="refnum" value="[[contactRef]]">
                <div class="formRow">
                    <label for="name-unhappy">Name* [[!+fi.error.name-unhappy:notempty=`<span class="label label-important">This is a required field.</span>`]]</label>
                </div>
                <div class="formRow [[!+fi.error.name-unhappy:notempty=`control-group error`]]" id="name-unhappy">
                    <input type="text" name="name-unhappy" value="[[!+fi.name-unhappy]]" class="input-block-level">
                </div>
                <div class="formRow">
                    <label for="email-unhappy">Email* [[!+fi.error.email-unhappy:notempty=`<span class="label label-important">This is a required field.</span>`]]</label>
                </div>
                <div class="formRow [[!+fi.error.email-unhappy:notempty=`control-group error`]]" id="email-unhappy">
                    <input type="text" name="email-unhappy" value="[[!+fi.email-unhappy]]" class="input-block-level">
                </div>
                <div class="formRow">
                    <div class="halfLeft">
                        <label for="batch-unhappy">Batch No./Date Code 
                            <a href="#" class="tooltip">
                                <i class="fa fa-question-circle"></i>
                                <span>
                                    <strong>FIND THE BATCH CODE HERE</strong>
                                    <img style="width:250px;" src="/images/structure/batch-code.jpg" alt="Batch Code" width="150" />
                                </span>
                            </a>
                        </span> [[!+fi.error.batch-unhappy:notempty=`<span class="label label-important">This is a required field.</span>`]]</label>
                    </div>
                    <div class="halfRight">
                        <label for="product-unhappy">Product [[!+fi.error.product-unhappy:notempty=`<span class="label label-important">This is a required field.</span>`]]</label>
                    </div>
                    <div class="clear"></div>
                </div>
                <div class="formRow">
                    <div class="halfLeft [[!+fi.error.batch-unhappy:notempty=`control-group error`]]" id="batch-unhappy">
                        <input type="text" name="batch-unhappy" value="[[!+fi.batch-unhappy]]" class="input-block-level">
                    </div>
                    <div class="halfRight [[!+fi.error.product-unhappy:notempty=`control-group error`]]" id="product-unhappy">
                        <input type="text" name="product-unhappy" value="[[!+fi.product-unhappy]]" class="input-block-level">
                    </div>
                    <div class="clear"></div>
                </div>
                <div class="formRow">
                    <label for="supermarket-unhappy">Which supermarket did you purchase this?</label>
                </div>
                <div class="formRow" id="supermarket-unhappy">
                    <input type="text" name="supermarket-unhappy" value="[[!+fi.supermarket-unhappy]]" class="input-block-level">
                </div>
                <div class="formRow">
                    <label for="supermarket-location-unhappy">What is the location of this supermarket?</label>
                </div>
                <div class="formRow" id="supermarket-location-unhappy">
                    <input type="text" name="location-unhappy" value="[[!+fi.supermarket-location-unhappy]]" class="input-block-level">
                </div>
                <div class="formRow">
                    <label for="address-unhappy">Your full address including postcode* [[!+fi.error.address-unhappy:notempty=`<span class="label label-important">This is a required field.</span>`]]</label>
                </div>
                <div class="formRow [[!+fi.error.address-unhappy:notempty=`control-group error`]]" id="address-unhappy">
                    <input type="text" name="address-unhappy" value="[[!+fi.address-unhappy]]" class="input-block-level">
                </div>
                <div class="formRow">
                    <label for="message-unhappy">Message* [[!+fi.error.message-unhappy:notempty=`<span class="label label-important">This is a required field.</span>`]]</label>
                </div>
                <div class="formRow [[!+fi.error.message-unhappy:notempty=`control-group error`]]" id="message-unhappy">
                    <textarea name="message-unhappy" cols="30" rows="10" value="[[!+fi.message-unhappy]]" class="input-block-level"></textarea>
                </div>
                <div class="formRow">
                    <input type="submit" value="Submit" name="submit-unhappy" class="btn btn-primary">
                    <div class="clear"></div>
                </div>
                <div class="formRow">
                    <p>
                    <input type="checkbox" name="marketing-unhappy[]" value="marketing-unhappy" [[!+fi.marketing-unhappy:FormItIsChecked=`marketing-unhappy`]] checked > 
                    <label class="note">I AM HAPPY TO RECEIVE UPDATES ABOUT PRODUCTS</label>
                    </p>
                    <p>
                    <input type="checkbox" name="third-marketing-unhappy[]" value="third-marketing-unhappy" [[!+fi.third-marketing-unhappy:FormItIsChecked=`third-marketing-unhappy`]] >
                    <label class="note">I AM HAPPY TO RECEIVE UPDATES FROM THIRD PARTIES</label>
                    </p>
                    <p>
                    <input type="checkbox" name="site-use-unhappy[]" value="site-use-unhappy" [[!+fi.site-use-unhappy:FormItIsChecked=`site-use-unhappy`]] checked >
                    <label class="note">I AM HAPPY FOR MY COMMENTS TO BE USED ON THE WEBSITE</label>
                    </p>
                </div>
            </form>
        </div>
    </div>


    Any ideas what might be causing the problems and please let me know if you need any more info.

    Thanks in advance [ed. note: cottoncreative last edited this post 11 years ago.]
      • 3749
      • 24,544 Posts
      You need to use &errTpl to set a different error placeholder for each form -- otherwise, they all have the same placeholder and will show it when FormIt sets it for any error.

      &errTpl=`[[+error_form_1]]`


      &errTpl=`[[+error_form_2]]`


      &errTpl=`[[+error_form_3]]`
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 50574
        • 70 Posts
        Thanks Bob.

        Where is that called within the form, something like:
        [[!+fi.error_form_1.name-unhappy:notempty=`<span class="label label-important">This is a required field.</span>`]]
        for example?
          • 3749
          • 24,544 Posts
          I'm afraid you've got me. I never actually use FormIt, though your idea looks good to me.

          Maybe someone else can help.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting