You are here

public function BootstrapSiteAlertAdmin::removeCallback in Bootstrap Site Alert 8

Submit handler for the "Remove Last Alert" button.

Decrements the max counter and causes a form rebuild.

File

src/Form/BootstrapSiteAlertAdmin.php, line 288

Class

BootstrapSiteAlertAdmin
Class BootstrapSiteAlertAdmin.

Namespace

Drupal\bootstrap_site_alert\Form

Code

public function removeCallback(array &$form, FormStateInterface $form_state) {
  $count = $form_state
    ->get('count');
  if ($count > 1) {
    $remove_button = $count - 1;
    $form_state
      ->set('count', $remove_button);
  }
  $form_state
    ->setRebuild();
  $this->ajaxPressed = TRUE;
}