You are here

public static function WebformElementStates::ajaxCallback in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Element/WebformElementStates.php \Drupal\webform\Element\WebformElementStates::ajaxCallback()

Webform submission Ajax callback the returns the states table.

File

src/Element/WebformElementStates.php, line 716

Class

WebformElementStates
Provides a webform element to edit an element's #states.

Namespace

Drupal\webform\Element

Code

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