You can easily hook into the validation process by implementing hook_form_alter(&$form, &$form_state, $form_id)
or it's cousin hook_form_FORM_ID_alter()
. There you can inspect the $form
variable, find out where the array of validation functions is, and perform array_unshift()
on it.
You could also use the form alter hooks to modify the #required
property of your title field, therefore preventing further validation errors down the line.
Don't forget that in order for your array_unshift()
operation to be successful, the form needs to be passed by reference to your hook, or else you would only be modifying a local copy of the form variable. It's very easy to forget adding the ampersand &
in front of $form
in the hook implementation. i.e. ...& $form
...