You are here

function ajax_validator in Ajax 6

Validation handler callback

Parameters

$form Assoc:

$form_state Assoc:

Return value

Bool

1 string reference to 'ajax_validator'
ajax_validator_set in ./ajax.module
Sets the validator

File

./ajax.module, line 430

Code

function ajax_validator(&$form, &$form_state) {
  if (array_key_exists('drupal_ajax', $_REQUEST)) {
    drupal_get_messages(NULL, TRUE);
    $data = ajax_build(array(
      'messages_error' => form_get_errors(),
      'form_id' => $form_state['values']['form_id'],
      'options' => $form['#ajax'],
    ));

    // FAIL
    if (!$data['status']) {
      ajax_invoke_validate_fail($form, $form_state, $data);
      ajax_out($data);
    }
    else {
      $pass = TRUE;
      ajax_invoke_validate_pass($form, $form_state, $data, $pass);
      if (!$pass) {
        ajax_out($data);
      }
    }
  }
  return TRUE;
}