We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I think I need some clarification here I remember using the error_message FormIt placeholder in order to display if there were any errors on a form.

    Well for some reason I am using it now and it does not work, was this changed in FormIt or am I doing something wrong?

    Here is my error_message code:

    [[!+fi.error_message:notempty=`<div id="errors">
            <p>Please review the following errors:</p>
    		<ul>
    			[[!+fi.error.name:notempty=`<li><a href="[[~[[*id]]]]#name">Name is a required field</a></li>`]]
    			[[!+fi.error.email:notempty=`<li><a href="[[~[[*id]]]]#email">Email is a required field</a></li>`]]
    			[[!+fi.error.comment:notempty=`<li><a href="[[~[[*id]]]]#comment">Comment is a required field</a></li>`]]
    		</ul>
    	</div>`]]
    


    I tried getting rid of the nested errors and it still doesn't work so I am really wondering what is going on.

    Thanks.

    This question has been answered by bertoost. See the first response.

    [ed. note: benmarte last edited this post 11 years, 1 month ago.]
      Benjamin Marte
      Interactive Media Developer
      Follow Me on Twitter | Visit my site | Learn MODX
    • discuss.answer
      The "error_message" contains an error message when something went wrong after validation. You should use "validation_error" instead. This one contains 0 or 1 if there are validation errors. So;

      [[!+fi.validation_error:notempty=`<div id="errors">
              <p>Please review the following errors:</p>
              <ul>
                  [[!+fi.error.name:notempty=`<li><a href="[[~[[*id]]]]#name">Name is a required field</a></li>`]]
                  [[!+fi.error.email:notempty=`<li><a href="[[~[[*id]]]]#email">Email is a required field</a></li>`]]
                  [[!+fi.error.comment:notempty=`<li><a href="[[~[[*id]]]]#comment">Comment is a required field</a></li>`]]
              </ul>
          </div>`]]


      You would also have a placeholder named "validation_error_message".
      See http://rtfm.modx.com/display/ADDON/FormIt.Validators
        MODX Ambassador (NL) & Professional MODX developer
        Follow me on Twitter | Visit my page on Facebook | View my code on Github | View my script posts
        MODX e-commerce solution SimpleCart
      • @bertoost thanks for clearing that up its working as I intended now, cheers.
          Benjamin Marte
          Interactive Media Developer
          Follow Me on Twitter | Visit my site | Learn MODX