[Form] Consider a violation even if the form is not submitted
This commit is contained in:
parent
00763f6e41
commit
c483a0f928
@ -275,9 +275,6 @@ class ViolationMapper implements ViolationMapperInterface
|
||||
*/
|
||||
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());
|
||||
return $this->allowNonSynchronized || $form->isSynchronized();
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
|
||||
}
|
||||
|
||||
public function testAbortMappingIfNotSubmitted()
|
||||
public function testMappingIfNotSubmitted()
|
||||
{
|
||||
$violation = $this->getConstraintViolation('children[address].data.street');
|
||||
$parent = $this->getForm('parent');
|
||||
@ -230,12 +230,12 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->mapper->mapViolation($violation, $parent);
|
||||
|
||||
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
|
||||
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one');
|
||||
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
|
||||
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error');
|
||||
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error');
|
||||
$this->assertCount(1, $grandChild->getErrors(), $grandChild->getName().' should have one error');
|
||||
}
|
||||
|
||||
public function testAbortDotRuleMappingIfNotSubmitted()
|
||||
public function testDotRuleMappingIfNotSubmitted()
|
||||
{
|
||||
$violation = $this->getConstraintViolation('data.address');
|
||||
$parent = $this->getForm('parent');
|
||||
@ -255,9 +255,9 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->mapper->mapViolation($violation, $parent);
|
||||
|
||||
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
|
||||
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one');
|
||||
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
|
||||
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error');
|
||||
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error');
|
||||
$this->assertCount(1, $grandChild->getErrors(), $grandChild->getName().' should have an error');
|
||||
}
|
||||
|
||||
public function provideDefaultTests()
|
||||
|
Reference in New Issue
Block a user