function FieldConfigEditForm::ajaxSubmit

Submit form #ajax callback.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

\Drupal\Core\Ajax\AjaxResponse An AJAX response that display validation error messages or represents a successful submission.

See also

\Drupal\Core\Ajax\AjaxFormHelperTrait

File

core/modules/field_ui/src/Form/FieldConfigEditForm.php, line 368

Class

FieldConfigEditForm
Provides a form for the field settings form.

Namespace

Drupal\field_ui\Form

Code

public function ajaxSubmit(array &$form, FormStateInterface $form_state) : AjaxResponse {
  if ($form_state->hasAnyErrors()) {
    $form['status_messages'] = [
      '#type' => 'status_messages',
      '#weight' => -1000,
    ];
    $form['#sorted'] = FALSE;
    $response = new AjaxResponse();
    $response->addCommand(new ReplaceCommand('#field-combined', $form));
  }
  else {
    $response = $this->successfulAjaxSubmit($form, $form_state);
  }
  return $response;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.