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

    It is possible to custimize the error message for the case, if a required input filed is empty:

    [[!+fi.error.email:notempty=`The email address field is empty.`]]


    But is it also possible to custimize the error message for the email validation? It should look like that:

    [[!+fi.error.email:email=`The email address is invalid.`]]


    Thanks
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      You can’t change that in the snippet call as far as I’m aware.

      You can, however, change the language set (which is called a Lexicon) to suit your needs.

      Go to System -> Lexicon Management.

      In the first dropdown, select "formit". In the language dropdown, select the language you want to change (or leave it to en).

      Then find the string you’re looking for, in this case formit.email_* (formit.email_invalid, formit.email_invalid_domain etc). Just double click the string and make the changes you’re looking for. It should save the changes automatically, but you will need to clear the cache to see effect.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 2459
        • 0 Posts
        Hello Mark,

        Thank you, I will try it out. But why does it not work in this way:

        [[!+fi.error.email:email=`The email address is invalid.`]]


        ?
          • 18373 ☆ A M B ☆
          • 3,141 Posts
          Because FormIt sets the placeholder "fi.error.email" to a certain string (the error) or nothing. That’s how FormIt was developed and how its developer intended it to be.

          On top of that, you are adding what is called an Output Modifier to it called "email" which doesn’t exist, unless you created a snippet with that name. You could make it work by creating a Snippet as the FormIt validators page tells you to, and checking for a the string you want to change.

          But the easy way if you just want to change the error message is (imo) to update the lexicons. It will stick on updates and doesn’t need php knowledge.
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.