Site with only mymodule and views (with dependences) enabled beside core modules.
If my validation function looks like this:
function mymodule_form_validate($form, &$form_state) {
// ...
form_set_error($element, $error);
// ...
}
errors are set during ajax call even if the button in question has
'#limit_validation_errors' => array(),
'#submit' => array(),
However, if I write it like this:
function mymodule_form_validate($form, &$form_state) {
$limit_validation_errors = $form_state['clicked_button']['#limit_validation_errors'];
// ...
form_set_error($element, $error, $limit_validation_errors);
// ...
}
it works just as it's supposed to.
Am I doing something wrong, or is there a bug somewhere?
Comments
Comment #1
David_Rothstein commentedWhat is stored in the $element variable in this case?
If it's a renderable array representing part of the form (which is what it sounds like from the variable name), then you want to call form_error() rather than form_set_error(). form_set_error() takes the name of the form element as input, not the element itself.
Comment #2
Mołot commented$element is a string "container_name][element_name". Sorry for misleading naming. It sets everything all right when it is supposed to.
Comment #2.0
Mołot commentedadded environment description