function EntityFormDisplay::validateFormValues

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php \Drupal\Core\Entity\Entity\EntityFormDisplay::validateFormValues()
  2. 8.9.x core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php \Drupal\Core\Entity\Entity\EntityFormDisplay::validateFormValues()
  3. 10 core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php \Drupal\Core\Entity\Entity\EntityFormDisplay::validateFormValues()

Overrides EntityFormDisplayInterface::validateFormValues

File

core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php, line 265

Class

EntityFormDisplay
Configuration entity.

Namespace

Drupal\Core\Entity\Entity

Code

public function validateFormValues(FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state) {
    $violations = $entity->validate();
    $violations->filterByFieldAccess();
    // Flag entity level violations.
    foreach ($violations->getEntityViolations() as $violation) {
        
        /** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
        $form_state->setError($form, $violation->getMessage());
    }
    $this->flagWidgetsErrorsFromViolations($violations, $form, $form_state);
}

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