We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10793
    • 0 Posts
    Dear Modx co-users, I need your help.

    I have a simple contact form, mutuated almost entirely from the templates and examples found online.
    It works and it validates the fields.

    Unfortunately, the error_message placeholder is driving me crazy:

    [[!+fi.error.error_message]]
    


    I copied them from the examples, but they do not show any message.

    When there is a validation error, the message displays correctly close to the wrong field BUT I expected to have the same message also displayed in the generic placeholder.

    Here below you find the FormIt call and the form itself.

    [[!FormIt?
       &hooks=`email`
       &emailTpl=`sentEmailTpl`
       &emailTo=`[email protected]`
       &validate=`contact_name:required:minLength=^2^,
                  contact_email:email:required,
                  contact_message:required`
       &clearFieldsOnSuccess=`1`
       &submitVar=`submit`
    ]]
     
    [[!+fi.error.error_message]]
    
    <form id="contactForm" class="vis-break brdr cmxform topspc" action="[[~[[*id]]]]" method="post">
    <img class="lft-img" src="[[*hrm20homedir]]images/email_s.png" alt="email" />
    <strong>Inviateci un email:</strong>
    <div>
    <label for="contact_name">Nome </label><em>(obbligatorio, almeno 2 caratteri)</em><br />
    <input id="contact_name" class="required" name="contact_name" size="30" value="[[!+fi.contact_name]]" />
    <span class="errore">[[!+fi.error.contact_name]]</span>
    </div>
    <div>
    <label for="contact_email">E-Mail </label><em>(obbligatorio)</em><br />
    <input id="contact_email" class="required email" name="contact_email" size="30" value="[[!+fi.contact_email]]" />
    <span class="errore">[[!+fi.error.contact_email]]</span>
    </div>
    <div>
    <label for="contact_phone">Telefono </label><em>(opzionale)</em><br />
    <input id="contact_phone" class="phone" maxlength="14" name="contact_phone" size="14" value="[[!+fi.contact_phone]]" />
    </div>
    <div>
    <label for="contact_message">Il vostro messaggio </label><em>(obbligatorio)</em>
    <span class="errore">[[!+fi.error.contact_message]]</span>
    <br />
    <textarea id="contact_message" class="required" cols="70" rows="7" name="contact_message">[[!+fi.contact_message]]</textarea>
    </div>
    <div>
    <input class="submit button yellow" name="submit" type="submit" value="Invio" />
    </div>
    </form>



    I’m using:
    - Modx Revo 2.0.8 (Traditional)
    - localhost
    - Ubuntu 10.04
    - PHP Version 5.3.2-1ubuntu4.9
    - Apache/2.2.14 (Ubuntu)
    - MySQL Server version: 5.1.41-3ubuntu12.10
    - Firefox and Chrome
    - no log errors
    - no chaching managers

    Thank you in advance

    Gianni

      • 27579
      • 2 Posts
      For validation error messages use this placeholder

      [[!+fi.validation_error_message]]


      you also need to change the default value for validationErrorMessage property

      &validationErrorMessage=`<p>A form validation error occurred: [[+errors]]</p>`


      I think the [[!+fi.error_message]] placeholder is only for Hook/preHook error messages.
        • 10793
        • 0 Posts
        Hi SWL, thanks for your help, now it works perfectly !

        Ciao

        gianni