You are here

public static function Zone::removeTerritorySubmit in Address 8

Submit callback for removing a territory.

File

src/Element/Zone.php, line 237

Class

Zone
Provides a zone form element.

Namespace

Drupal\address\Element

Code

public static function removeTerritorySubmit(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);
  $territory_index = $triggering_element['#territory_index'];
  unset($element_state['territories'][$territory_index]);
  self::setElementState($element_parents, $form_state, $element_state);
  $form_state
    ->setRebuild();
}