function FieldConfigEditForm::addAjaxCallbacks

Same name and namespace in other branches
  1. 11.x core/modules/field_ui/src/Form/FieldConfigEditForm.php \Drupal\field_ui\Form\FieldConfigEditForm::addAjaxCallbacks()

Add Ajax callback for all inputs.

Parameters

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

1 call to FieldConfigEditForm::addAjaxCallbacks()
FieldConfigEditForm::form in core/modules/field_ui/src/Form/FieldConfigEditForm.php

File

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

Class

FieldConfigEditForm
Provides a form for the field settings form.

Namespace

Drupal\field_ui\Form

Code

private function addAjaxCallbacks(array &$form) : void {
  if (isset($form['#type']) && !isset($form['#ajax'])) {
    if ($this->elementInfo
      ->getInfoProperty($form['#type'], '#input') && !$this->elementInfo
      ->getInfoProperty($form['#type'], '#is_button')) {
      $form['#ajax'] = [
        'trigger_as' => [
          'name' => 'field_storage_submit',
        ],
        'wrapper' => 'field-combined',
        'event' => 'change',
      ];
    }
  }
  foreach (Element::children($form) as $child_key) {
    $this->addAjaxCallbacks($form[$child_key]);
  }
}

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