diff --git a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php index f8795593bbb18..d75636888f311 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php +++ b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php @@ -29,6 +29,11 @@ class ViolationMapper implements ViolationMapperInterface */ private $allowNonSynchronized; + /** + * @var bool + */ + private $formSubmissionRequired = true; + /** * {@inheritdoc} */ @@ -292,9 +297,29 @@ private function reconstructPath(ViolationPath $violationPath, FormInterface $or */ private function acceptsErrors(FormInterface $form) { - // Ignore non-submitted forms. This happens, for example, in PATCH - // requests. - // https://github.com/symfony/symfony/pull/10567 - return $form->isSubmitted() && ($this->allowNonSynchronized || $form->isSynchronized()); + if ($this->isFormSubmissionRequired()) { + // Ignore non-submitted forms. This happens, for example, in PATCH + // requests. + // https://github.com/symfony/symfony/pull/10567 + return $form->isSubmitted() && ($this->allowNonSynchronized || $form->isSynchronized()); + } + + return $this->allowNonSynchronized || $form->isSynchronized(); + } + + /** + * @param bool $formSubmissionRequired + */ + public function setFormSubmissionRequired($formSubmissionRequired) + { + $this->formSubmissionRequired = (bool) $formSubmissionRequired; + } + + /** + * @return bool + */ + private function isFormSubmissionRequired() + { + return $this->formSubmissionRequired; } }