I know that you can do on form_alter one validation function:

                $form['#validate'] = array('my_validation_function');

But what if some other module want to validate the same form with other function and not replacing existing one?

Comments

jonathanpglick’s picture

Define two at once:

$form['#validate'] = array('validation_1', 'validation_2');

Add a validation function to the existing ones:

$form['#validate'][] = 'new_validation_function';
kenorb’s picture

That's the problem, second method doesn't work.

But this syntax is working fine:
$form['#validate']['new_validation_function'] = 'new_validation_function';

Any link to proper documentation how it should looks like?
Why it's so unfriendly?

ibragim’s picture

>Why it's so unfriendly?
because it's drupal

ibragim’s picture

to validate some form do next:

function module_name_form_alter($form_id, &$form){
	if ($form_id == "some_form_form"){
   	   $form["#validate"]["val_func"] = array("val_func");
	}
}
function val_func($form_id, &$form_values){
// validate your form here	
}