New Community Forums are coming. Watch this space for news.
Subscribe: RSS
  • 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=`Profiles@xjtlu.edu.cn`
    &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="News@xjtlu.edu.cn" [[!+fi.teamselect:FormItIsSelected=`News@xjtlu.edu.cn`]] >News</option>
    <option value="News@xjtlu.edu.cn" [[!+fi.teamselect:FormItIsSelected=`News@xjtlu.edu.cn`]] >Events</option>
    <option value="Marketing@xjtlu.edu.cn" [[!+fi.teamselect:FormItIsSelected=`Marketing@xjtlu.edu.cn`]] >Web Content Update</option>
    <option value="zhefei.zhu@xjtlu.edu.cn" [[!+fi.teamselect:FormItIsSelected=`zhefei.zhu@xjtlu.edu.cn`]] >Web Tech Matters</option>
    <option value="439973358@qq.com" [[!+fi.teamselect:FormItIsSelected=`439973358@qq.com`]] >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>
    • 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=`Profiles@xjtlu.edu.cn`
      &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`]]`

      • &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: contact@antontarasov.com
          Web: antontarasov.com
        • 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.