You are here

public function GeolocationBlock::removeCallback in Geolocation Field 8.3

Add location.

Parameters

array $form: Current form.

\Drupal\Core\Form\FormStateInterface $form_state: Current form state.

File

src/Plugin/Block/GeolocationBlock.php, line 261

Class

GeolocationBlock
Exposes a map rendered as a block.

Namespace

Drupal\geolocation\Plugin\Block

Code

public function removeCallback(array &$form, FormStateInterface &$form_state) {
  $parents = $form_state
    ->getTriggeringElement()['#parents'];
  end($parents);
  $key = prev($parents);
  $locations = $form_state
    ->get('locations');
  unset($locations[$key]);
  $form_state
    ->set('locations', $locations);
  $form_state
    ->setRebuild();
}