You are here

public function FloodUnblockAdminForm::validateForm in Flood Unblock 8.2

Same name and namespace in other branches
  1. 8 src/Form/FloodUnblockAdminForm.php \Drupal\flood_unblock\Form\FloodUnblockAdminForm::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/FloodUnblockAdminForm.php, line 125

Class

FloodUnblockAdminForm
Admin form of Flood unblock.

Namespace

Drupal\flood_unblock\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);
  $entries = $form_state
    ->getValue('table');
  $selected_entries = array_filter($entries, function ($selected) {
    return $selected !== 0;
  });
  if (empty($selected_entries)) {
    $form_state
      ->setErrorByName('table', $this
      ->t('Please make a selection.'));
  }
}