You are here

public function AnonymousPublishingClAdminModeration::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/AnonymousPublishingClAdminModeration.php, line 200

Class

AnonymousPublishingClAdminModeration
This class defines the moderation setting form for this module, available at : admin/config/people/anonymous_publishing_cl/moderation

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.'));
  }
}