10BC0 [Form] Consider a violation even if the form is not submitted · symfony/symfony@c483a0f · GitHub
[go: up one dir, main page]

Skip to content

Commit c483a0f

Browse files
committed
[Form] Consider a violation even if the form is not submitted
1 parent 00763f6 commit c483a0f

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,6 @@ private function reconstructPath(ViolationPath $violationPath, FormInterface $or
275275
*/
276276
private function acceptsErrors(FormInterface $form)
277277
{
278-
// Ignore non-submitted forms. This happens, for example, in PATCH
279-
// requests.
280-
// https://github.com/symfony/symfony/pull/10567
281-
return $form->isSubmitted() && ($this->allowNonSynchronized || $form->isSynchronized());
278+
return $this->allowNonSynchronized || $form->isSynchronized();
282279
}
283280
}

src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public function testAbortDotRuleMappingIfNotSynchronized()
212212
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
213213
}
214214

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

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

233-
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
234-
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one');
235-
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
233+
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error');
234+
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error');
235+
$this->assertCount(1, $grandChild->getErrors(), $grandChild->getName().' should have one error');
236236
}
237237

238-
public function testAbortDotRuleMappingIfNotSubmitted()
238+
public function testDotRuleMappingIfNotSubmitted()
239239
{
240240
$violation = $this->getConstraintViolation('data.address');
241241
$parent = $this->getForm('parent');
@@ -255,9 +255,9 @@ public function testAbortDotRuleMappingIfNotSubmitted()
255255

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

258-
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
259-
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one');
260-
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
258+
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error');
259+
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error');
260+
$this->assertCount(1, $grandChild->getErrors(), $grandChild->getName().' should have an error');
261261
}
262262

263263
public function provideDefaultTests()

0 commit comments

Comments
 (0)
0