You are here

public function AmswapConfigForm::amswap_delete_pair in Admin Menu Swap 7.2

File

src/Form/AmswapConfigForm.php, line 114

Class

AmswapConfigForm
Class AmswapConfigForm.

Namespace

Drupal\amswap\Form

Code

public function amswap_delete_pair(array $form, FormStateInterface &$form_state) {

  // kint($form_state, '$form_state');
  $button = $form_state
    ->getTriggeringElement();

  // kint($button, '$button');
  $item = $button['#attributes']['pair_num'];
  $form_state
    ->unsetValue('pair-' . $item . '-role');
  $form_state
    ->unsetValue('pair-' . $item . '-menu');
  $msg = t('Pair ' . ($item + 1) . ' removed. Other pairs saved.');
  drupal_set_message($msg, 'status', FALSE);
  $this
    ->submitForm($form, $form_state);
}