3

In my theme I'm already using the hook_form_alter to customize the form fields but now I want to customize the validation error messages.

After some research, the only way I'm finding is to write a whole separate function and custom error handling of each form field.

I don't want to reinvent the wheel. Isn't there just a simple way to change the default form validation error so I can get away from "XYZ field is required?"

2
  • 1
    Hi and welcome to DA. Is the validation error message a normal status message or rather some javascript message showing up close to the field validated?
    – q9f
    Commented Jun 7, 2013 at 6:04
  • By customize you mean to change strings or the way it looks?
    – Mołot
    Commented Jun 7, 2013 at 6:41

1 Answer 1

2

There are a number of options to resolve this issue:

  1. One option is using the String Overrides module to replace the string used to generate the message.
  2. Another option is to create a custom module that overrides the validation function for a particular form or field, replacing any error messages with the messages of your choosing.
  3. The following link may also help:
1
  • Option 2 is what I'm currently working on. I was just thinking there would be an easier way to do it.
    – LeoXela
    Commented Jun 7, 2013 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.