Skip to content

Commit

Permalink
Revert "bug #18935 [Form] Consider a violation even if the form is no…
Browse files Browse the repository at this point in the history
…t submitted (egeloen)"

This reverts commit f28eb9a6172d44217186c11b78841fd3efcbb6f4, reversing
changes made to bbb75faa15c995b4b11ccf71a53618c570bb58eb.
  • Loading branch information
fabpot committed Aug 29, 2016
1 parent a33d9e6 commit 498a795
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion Extension/Validator/ViolationMapper/ViolationMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ private function reconstructPath(ViolationPath $violationPath, FormInterface $or
*/
private function acceptsErrors(FormInterface $form)
{
return $this->allowNonSynchronized || $form->isSynchronized();
// 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function testAbortDotRuleMappingIfNotSynchronized()
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
}

public function testMappingIfNotSubmitted()
public function testAbortMappingIfNotSubmitted()
{
$violation = $this->getConstraintViolation('children[address].data.street');
$parent = $this->getForm('parent');
Expand All @@ -230,12 +230,12 @@ public function testMappingIfNotSubmitted()

$this->mapper->mapViolation($violation, $parent);

$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');
$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');
}

public function testDotRuleMappingIfNotSubmitted()
public function testAbortDotRuleMappingIfNotSubmitted()
{
$violation = $this->getConstraintViolation('data.address');
$parent = $this->getForm('parent');
Expand All @@ -255,9 +255,9 @@ public function testDotRuleMappingIfNotSubmitted()

$this->mapper->mapViolation($violation, $parent);

$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');
$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');
}

public function provideDefaultTests()
Expand Down

0 comments on commit 498a795

Please sign in to comment.