You are here

public static function Address::ajaxRefresh in Address 8

Ajax callback.

File

src/Element/Address.php, line 373

Class

Address
Provides an address form element.

Namespace

Drupal\address\Element

Code

public static function ajaxRefresh(array $form, FormStateInterface $form_state) {
  $triggering_element = $form_state
    ->getTriggeringElement();
  $parents = $triggering_element['#array_parents'];
  $triggering_element_name = array_pop($parents);

  // The country_code element is nested one level deeper than
  // the subdivision elements.
  if ($triggering_element_name == 'country_code') {
    array_pop($parents);
  }
  $address_element = NestedArray::getValue($form, $parents);
  return $address_element;
}