Hi there,

I'm looking the proper way to validate elements added by hook_form_alter().
Is there a hook similar to hook_validate() which works for new elements ?
or should I use '#validate' field in element definition ?

cheers

Comments

kuba.zygmunt’s picture

It is very easy in D6

When you add form elements by hook_alter(), add also :

$form['#validate'][] = 'another_validating_function';
ferrum’s picture

I had the same problem and searched in books and official documentation but found only many questions regarding this issue and some hints how it could be solved.
Thanks for this hint.
I also wonder whether it is not mentioned in the hook_form_alter() documentation how to validate and save the changed or added elements?