You are here

public static function YamlFormElementStates::ajaxCallback in YAML Form 8

Form submission AJAX callback the returns the states table.

File

src/Element/YamlFormElementStates.php, line 466

Class

YamlFormElementStates
Provides a form element to edit an element's #states.

Namespace

Drupal\yamlform\Element

Code

public static function ajaxCallback(array &$form, FormStateInterface $form_state) {
  $button = $form_state
    ->getTriggeringElement();
  $parent_length = isset($button['#row_index']) ? -4 : -1;
  $element = NestedArray::getValue($form, array_slice($button['#array_parents'], 0, $parent_length));
  return $element['states'];
}