You are here

public static function Zone::addTerritorySubmit in Address 8

Submit callback for adding a new territory.

File

src/Element/Zone.php, line 225

Class

Zone
Provides a zone form element.

Namespace

Drupal\address\Element

Code

public static function addTerritorySubmit(array $form, FormStateInterface $form_state) {
  $triggering_element = $form_state
    ->getTriggeringElement();
  $element_parents = array_slice($triggering_element['#parents'], 0, -3);
  $element_state = self::getElementState($element_parents, $form_state);
  $element_state['territories'][] = NULL;
  self::setElementState($element_parents, $form_state, $element_state);
  $form_state
    ->setRebuild();
}