0

I have modified the node add and edit form for one of my custom types, adding a few ajax callbacks: a couple are on the onchange values of text fields, one on the autocompleteclose of an autocomplete field. Now I started to add form validation, but it seems I cannot limit it to the submit button, it is always called on ajax callbacks. I found out about limit_validation_errors, but if I understood correctly that can only be added to submit buttons; I tried to add it to one of my ajax callbacks in this way:

$form['my-data-input'] = array(
  '#type' => 'textfield',
  '#title' => 'Date',
  '#size' => 30,
  '#maxlength' => 30,
  '#limit_validation_errors' => [],
  '#ajax' => array(
    'callback' => 'my_datetime_changed',
    'event' => 'change',
    'wrapper' => 'my-container',
    'progress' => array(
      '#type' => 'throbber',
      'message' => 'Loading...',
    ),
  ),
);

but that has no effect at all, as I may have guessed.

I don't want form validation on any of my ajax calls, is there a way to achieve this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.