You are here

public function AnonymousPublishingClAdminSpam::validateForm in Anonymous Publishing 8

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

modules/anonymous_publishing_cl/src/Form/AnonymousPublishingClAdminSpam.php, line 189

Class

AnonymousPublishingClAdminSpam

Namespace

Drupal\anonymous_publishing_cl\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $form_state
    ->setValue('items', array_diff($form_state
    ->getValue('items'), array(
    0,
  )));

  // We can't execute any 'Update options' if no items were selected.
  if (count($form_state
    ->getValue('items')) == 0) {
    $form_state
      ->setErrorByName('', $this
      ->t('Select one or more items to perform the update on.'));
  }
}