By wheelercreek on
Okay - strange question. Assume module A creates a form, and has a form_validate function in it. I need to add a little extra validation to that specific form, but can't touch module A (long story).
Can I do it with a new module (module B)?
I'm trying this just to test:
function moduleA_form_validate($form, &$form_state)
{
drupal_set_message('howdy');
}
Not getting any results.
Thanks
Comments
Yes there is a trick you can
Yes there is a trick you can use to do it.
First in your Module B, use hook_form_alter to inject (or overwrite) your own validation function into the "#validate" attribute of said form. (example => http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....)
Then your validation function will also be called.
cheers
wheelercreek, If you want to
wheelercreek,
If you want to preserve the existing validation and submit processing, you can poke your own function in front the queue:
This should ensure that your function is called before (or after) the remaining list of validation handlers - whatever they might be.
Martin