You are here

public function ForwardForm::validateForm in Forward 8

Same name and namespace in other branches
  1. 8.3 src/Form/ForwardForm.php \Drupal\forward\Form\ForwardForm::validateForm()
  2. 8.2 src/Form/ForwardForm.php \Drupal\forward\Form\ForwardForm::validateForm()
  3. 4.x src/Form/ForwardForm.php \Drupal\forward\Form\ForwardForm::validateForm()
  4. 4.0.x src/Form/ForwardForm.php \Drupal\forward\Form\ForwardForm::validateForm()

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormBase::validateForm

File

src/Form/ForwardForm.php, line 423

Class

ForwardForm
Forward a page to a friend

Namespace

Drupal\forward\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  if (!$this
    ->currentUser()
    ->hasPermission('override flood control')) {
    $event = $this
      ->getFloodControlEventName();
    if (!$this->floodInterface
      ->isAllowed($event, $this->settings['forward_flood_control_limit'])) {
      $message = new FormattableMarkup($this->settings['forward_flood_control_error'], [
        '@number' => $this->settings['forward_flood_control_limit'],
      ]);
      $form_state
        ->setErrorByName('', $message);
    }
  }
  parent::validateForm($form, $form_state);
}