function EntityFormDisplay::flagWidgetsErrorsFromViolations

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

Overrides EntityFormDisplayInterface::flagWidgetsErrorsFromViolations

1 call to EntityFormDisplay::flagWidgetsErrorsFromViolations()
EntityFormDisplay::validateFormValues in core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
Validates submitted widget values and sets the corresponding form errors.

File

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

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 flagWidgetsErrorsFromViolations(EntityConstraintViolationListInterface $violations, array &$form, FormStateInterface $form_state) {
    $entity = $violations->getEntity();
    foreach ($violations->getFieldNames() as $field_name) {
        // Only show violations for fields that actually appear in the form, and
        // let the widget assign the violations to the correct form elements.
        if ($widget = $this->getRenderer($field_name)) {
            $field_violations = $this->movePropertyPathViolationsRelativeToField($field_name, $violations->getByField($field_name));
            $widget->flagErrors($entity->get($field_name), $field_violations, $form, $form_state);
        }
    }
}

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