Skip to content
Snippets Groups Projects
Commit f1c9c9fb authored by Oleh Tarasiuk's avatar Oleh Tarasiuk Committed by Andrii Podanenko
Browse files

Issue #3358843 fix multiple errors while validating entity

parent 7218f544
Branches
Tags
2 merge requests!99Closes #3359875,!69Issue #3358843 fix multiple errors while validating entity
......@@ -266,15 +266,19 @@ class EntityInlineForm implements InlineFormInterface {
$entity = $entity_form['#entity'];
$this->buildEntity($entity_form, $entity, $form_state);
$form_display = $this->getFormDisplay($entity, $entity_form['#form_mode']);
$form_display->validateFormValues($entity, $entity_form, $form_state);
$entity->setValidationRequired(FALSE);
foreach ($form_state->getErrors() as $message) {
// $name may be unknown in $form_state and
// $form_state->setErrorByName($name, $message) may suppress the error
// message.
$form_state->setError($triggering_element, $message);
// Do the entity validation.
$violations = $entity->validate();
$violations->filterByFieldAccess();
// Flag entity level violations.
foreach ($violations->getEntityViolations() as $violation) {
/** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
$form_state->setError($triggering_element, $violation->getMessage());
}
$form_display->flagWidgetsErrorsFromViolations($violations, $entity_form, $form_state);
$entity->setValidationRequired(FALSE);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment