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

David_Rothstein’s picture

Status: Active » Postponed (maintainer needs more info)

What 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.

Mołot’s picture

Status: Postponed (maintainer needs more info) » Active

$element is a string "container_name][element_name". Sorry for misleading naming. It sets everything all right when it is supposed to.

Mołot’s picture

Issue summary: View changes

added environment description

Version: 7.22 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.