I'm sure there's some simple reason that my custom validate function isn't executing.
Here's my code:
function MYMODULE_form_message_ui_instance_message_manage_alter(&$form, &$form_state, $form_id) {
array_unshift($form['#validate'], 'MYMODULE_validate_relationship');
watchdog("form", "<pre>" . print_r($form, true) . "</pre>");
}
function MYMODULE_validate_relationship($form, &$form_state) {
watchdog("validate form state", "<pre>" . print_r($form_state, true) . "</pre>");
watchdog("validate form", "<pre>" . print_r($form, true) . "</pre>");
}
On form submission, the first watchdog - "form" is being exected, however the second and third are not. Why is this? I can't find any information on why a custom validate hook wouldn't execute.
EDIT per Pierre's request:
I am writing a custom validation function that I am trying to execute before the other validation functions. I am doing this using array_unshift. This seems to be working, as my #validate array looks like this:
[#validate] => Array
(
[0] => MYMODULE_validate_relationship
[1] => message_ui_instance_message_manage_validate
[2] => message_private_form_message_private_instance_message_manage_validate
)
However the code in MYMODULE_validate_relationship is never executing.
As far as I can tell, $form and &$form should be irrelevant in the validate function, because once you're at the validation stage, nothing should actually be modifying the form (I think?). And most examples I was seeing did not including passing the $form by reference. And I've tried both ways, and in neither way is the validate hook firing.