function CommentAdminOverview::validateForm

Same name and namespace in other branches
  1. 8.9.x core/modules/comment/src/Form/CommentAdminOverview.php \Drupal\comment\Form\CommentAdminOverview::validateForm()
  2. 10 core/modules/comment/src/Form/CommentAdminOverview.php \Drupal\comment\Form\CommentAdminOverview::validateForm()
  3. 11.x core/modules/comment/src/Form/CommentAdminOverview.php \Drupal\comment\Form\CommentAdminOverview::validateForm()

Overrides FormBase::validateForm

File

core/modules/comment/src/Form/CommentAdminOverview.php, line 257

Class

CommentAdminOverview
Provides the comments overview administration form.

Namespace

Drupal\comment\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
    $form_state->setValue('comments', array_diff($form_state->getValue('comments'), [
        0,
    ]));
    // We can't execute any 'Update options' if no comments were selected.
    if (count($form_state->getValue('comments')) == 0) {
        $form_state->setErrorByName('', $this->t('Select one or more comments to perform the update on.'));
    }
}

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