function BanAdmin::submitForm

Same name in other branches
  1. 8.9.x core/modules/ban/src/Form/BanAdmin.php \Drupal\ban\Form\BanAdmin::submitForm()
  2. 10 core/modules/ban/src/Form/BanAdmin.php \Drupal\ban\Form\BanAdmin::submitForm()
  3. 11.x core/modules/ban/src/Form/BanAdmin.php \Drupal\ban\Form\BanAdmin::submitForm()

Overrides FormInterface::submitForm

File

core/modules/ban/src/Form/BanAdmin.php, line 125

Class

BanAdmin
Displays banned IP addresses.

Namespace

Drupal\ban\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    $ip = trim($form_state->getValue('ip'));
    $this->ipManager
        ->banIp($ip);
    $this->messenger()
        ->addStatus($this->t('The IP address %ip has been banned.', [
        '%ip' => $ip,
    ]));
    $form_state->setRedirect('ban.admin_page');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.