We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 54277
    • 8 Posts
    Following is my code, but it still is not able to display success message, what's my wrong?

    [[!FormIt?
    &hooks=`email,attachment`
    &emailTpl=`[[+emailChunk]]`
    &emailTo=`[[+teamselect]]`
    &attachment=`[[+filedata]]`
    &emailSubject=`Request from [[+formName]]`
    &emailFromName=`Profiles`
    &emailFrom=`[email protected]`
    &validate=`[[+validation:default=`
    formName:required,
    formEmailAddress:email:required,
    teamselect:required,
    formQuery:required,
    whatAreYouDoing:blank
    `]]`
    &successMessage=`Your comment has been submitted successfully.`
    &validationErrorMessage=`<div class="alert alert-error">
    <h3>Please review the following errors:</h3>
    <ul>
    [[!+fi.error.formName:!empty=`<li><a href="[[~[[*id]]]]#formName">Name is a required field</a></li>`]]
    [[!+fi.error.formEmailAddress:!empty=`<li><a href="[[~[[*id]]]]#formEmailAddress">Email is a required field</a></li>`]]
    </ul>
    </div>`
    ]]


    [[!+fi.validation_error_message:!empty=`
    <div class="alert alert-error xjtlurequest">
    <h3>Please review the following errors:</h3>
    <ul>
    [[!+fi.error.formName:!empty=`<li><a href="[[~[[*id]]]]#formName">Name is a required field</a></li>`]]
    [[!+fi.error.formEmailAddress:!empty=`<li><a href="[[~[[*id]]]]#formEmailAddress">Email is a required field</a></li>`]]
    </ul>
    </div>`]]

    [[!fi.successMessage]]

    <div class="well xjtlurequest">
    <form method="post" action="[[~[[*id]]]]" id="[[+formId:default=`contact-us`]]" enctype="multipart/form-data">
    <fieldset>
    <legend>Contact Us</legend>
    <input type="hidden" value="[[*pagetitle]]" name="formPage" id="formPage">
    <p>
    <label for="formName">Name [[!+fi.error.formName:notempty=`[[!+fi.error.formName]]`]]</label>
    <input type="text" name="formName" id="formName" value="[[!+fi.formName]]">
    </p>
    <p>
    <label for="formEmailAddress">Email [[!+fi.error.formEmailAddress:notempty=`[[!+fi.error.formEmailAddress]]`]]</label>
    <input type="email" name="formEmailAddress" id="formEmailAddress" value="[[!+fi.formEmailAddress]]">
    </p>
    <p>
    <label for="formPhoneNumber">Telephone [[!+fi.error.formPhoneNumber:notempty=`[[!+fi.error.formPhoneNumber]]`]]</label>
    <input type="text" name="formPhoneNumber" id="formPhoneNumber" value="[[!+fi.formPhoneNumber]]">
    </p>

    <label for="teamselect">Please chose a thing for requesting....
    [[!+fi.error.teamselect:notempty=`[[!+fi.error.teamselect]]`]]</label>
    <select name="teamselect">
    <option value="[email protected]" [[!+fi.teamselect:FormItIsSelected=`[email protected]`]] >News</option>
    <option value="[email protected]" [[!+fi.teamselect:FormItIsSelected=`[email protected]`]] >Events</option>
    <option value="[email protected]" [[!+fi.teamselect:FormItIsSelected=`[email protected]`]] >Web Content Update</option>
    <option value="[email protected]" [[!+fi.teamselect:FormItIsSelected=`[email protected]`]] >Web Tech Matters</option>
    <option value="[email protected]" [[!+fi.teamselect:FormItIsSelected=`[email protected]`]] >General Matters</option>
    </select>

    <p>
    <label for="formQuery">Request [[!+fi.error.formQuery:notempty=`[[!+fi.error.formQuery]]`]]</label>
    <textarea rows="5" cols="30" name="formQuery" id="formQuery" wrap="hard">[[!+fi.formQuery]]</textarea>
    </p>

    <p>
    <input id="filedata" name="filedata" type="file" value="[[+fi.filedata]]">
    </p>

    <p>
    <button type="submit">Send</button>
    <input type="hidden" name="whatAreYouDoing" value="">
    [[!FormItRetriever]]
    </p>
    </fieldset>
    </form>
    </div>
      • 46886
      • 1,154 Posts
      Could try to put it above the validation?

      [[!FormIt?
      &hooks=`email,attachment`
      &emailTpl=`[[+emailChunk]]`
      &emailTo=`[[+teamselect]]`
      &attachment=`[[+filedata]]`
      &emailSubject=`Request from [[+formName]]`
      &emailFromName=`Profiles`
      &emailFrom=`[email protected]`
      &successMessage=`Your comment has been submitted successfully.`
      &validate=`[[+validation:default=`
      ...


      And I really don't like this, but I could be wrong

      &validate=`[[+validation:default=`
      formName:required,
      formEmailAddress:email:required,
      teamselect:required,
      formQuery:required,
      whatAreYouDoing:blank 
      `]]`


      I think it should be

      &validate=`[[+validation:default=`
      formName:required,
      formEmailAddress:email:required,
      teamselect:required,
      formQuery:required,
      whatAreYouDoing:blank`]]`

        • 44064
        • 185 Posts
        &validate=`[[+validation:default=`
        formName:required,
        formEmailAddress:email:required,
        teamselect:required,
        formQuery:required,
        whatAreYouDoing:blank`]]`


        Soo complex)) Please try with simpler(without conditions) validation first, as soon as you get result and success message you can update your validation conditions. Otherwise error can be hidden here and Formit fails.
          Anton Tarasov
          MODX Developer

          Email: [email protected]
          Web: antontarasov.com
          • 46886
          • 1,154 Posts
          Yes himurovich is right, simplify when debugging and build up from there

          And also zzfkelvin you can use error codes in there to warn you at each step if something is going wrong.