Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f5812c5

Browse filesBrowse files
committed
[Form] Let null values to unset fields in PATCH requests
1 parent b85b78f commit f5812c5
Copy full SHA for f5812c5

File tree

Expand file treeCollapse file tree

2 files changed

+14
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-1
lines changed

‎src/Symfony/Component/Form/Form.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Form.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ public function submit($submittedData, $clearMissing = true)
548548
}
549549

550550
foreach ($this->children as $name => $child) {
551-
if (isset($submittedData[$name]) || $clearMissing) {
551+
if (array_key_exists($name, $submittedData) || $clearMissing) {
552552
$child->submit(isset($submittedData[$name]) ? $submittedData[$name] : null, $clearMissing);
553553
unset($submittedData[$name]);
554554
}

‎src/Symfony/Component/Form/Tests/CompoundFormTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/CompoundFormTest.php
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,19 @@ public function testDisabledFormsValidEvenIfChildrenInvalid()
8282
$this->assertTrue($form->isValid());
8383
}
8484

85+
public function testSubmitForwardsNullIfNotClearMissingButValueIsExplicitlyNull()
86+
{
87+
$child = $this->getMockForm('firstName');
88+
89+
$this->form->add($child);
90+
91+
$child->expects($this->once())
92+
->method('submit')
93+
->with($this->equalTo(null));
94+
95+
$this->form->submit(array('firstName' => null), false);
96+
}
97+
8598
public function testSubmitForwardsNullIfValueIsMissing()
8699
{
87100
$child = $this->getMockForm('firstName');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.