You are here

public function AmswapConfigForm::deletePair in Admin Menu Swap 8

File

src/Form/AmswapConfigForm.php, line 152

Class

AmswapConfigForm
Class AmswapConfigForm.

Namespace

Drupal\amswap\Form

Code

public function deletePair(array $form, FormStateInterface &$form_state) {
  $button = $form_state
    ->getTriggeringElement();
  $item = $button['#attributes']['pair_num'];
  $form_state
    ->unsetValue('pair-' . $item . '-role');
  $form_state
    ->unsetValue('pair-' . $item . '-menu');
  $msg = $this
    ->t('Pair @i removed. Other pairs saved.', [
    '@i' => $item + 1,
  ]);
  $this
    ->messenger()
    ->addStatus($msg, FALSE);
  $this
    ->submitForm($form, $form_state);
}