function CommentForm::flagViolations

Same name in other branches
  1. 8.9.x core/modules/comment/src/CommentForm.php \Drupal\comment\CommentForm::flagViolations()
  2. 10 core/modules/comment/src/CommentForm.php \Drupal\comment\CommentForm::flagViolations()
  3. 11.x core/modules/comment/src/CommentForm.php \Drupal\comment\CommentForm::flagViolations()

Overrides ContentEntityForm::flagViolations

File

core/modules/comment/src/CommentForm.php, line 343

Class

CommentForm
Base handler for comment forms.

Namespace

Drupal\comment

Code

protected function flagViolations(EntityConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state) {
    // Manually flag violations of fields not handled by the form display.
    foreach ($violations->getByField('created') as $violation) {
        $form_state->setErrorByName('date', $violation->getMessage());
    }
    foreach ($violations->getByField('name') as $violation) {
        $form_state->setErrorByName('name', $violation->getMessage());
    }
    parent::flagViolations($violations, $form, $form_state);
}

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