In a form_validate hook, I have some custom validation and I’m using
form_set_error('field_foo', "error_message");
to show validation errors. If the validation returns an error that is not linked to a particular form field, how do I show the error, indipendently? (For example: the error is you compiled more that three times the form.)
EDIT: I though to use:
drupal_set_message("error_message", 'error');
From the documentaion for 7.x
When a validation error is detected, the validator calls form_set_error() to indicate which element needs to be changed and provide an error message.
So, form_set_error() produce an error linked to a particular field of the form. I needed to display error indipendently in a custom complex validation, being errors not really about a field. I though to use form_set_error() on a random field, but it is not the perfect solution, for the field was highlighted and only the last error produced this way was visible. drupal_set_message solves this two problem, but the validation success and the form continues like there was no error.