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. 10 core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php \Drupal\Core\Entity\Entity\EntityFormDisplay::validateFormValues()
  3. 11.x 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 242

Class

EntityFormDisplay
Configuration entity that contains widget options for all components of a entity form in a given form mode.

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.