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 de1915f

Browse filesBrowse files
committed
merged branch Flask/ticket_8548 (PR #8575)
This PR was squashed before being merged into the 2.3 branch (closes #8575). Discussion ---------- [Form] fixes empty file-inputs get treated as extra field | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #8548, #8566 | License | MIT Commits ------- e5fba3c [Form] fixes empty file-inputs get treated as extra field
2 parents 364ccd1 + e5fba3c commit de1915f
Copy full SHA for de1915f

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+15
-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
@@ -546,7 +546,7 @@ public function submit($submittedData, $clearMissing = true)
546546

547547
foreach ($this->children as $name => $child) {
548548
$fieldValue = null;
549-
if (isset($submittedData[$name])) {
549+
if (array_key_exists($name, $submittedData)) {
550550
$fieldValue = $submittedData[$name];
551551
unset($submittedData[$name]);
552552
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/CompoundFormTest.php
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler;
1515
use Symfony\Component\Form\FormError;
16+
use Symfony\Component\Form\Forms;
1617
use Symfony\Component\HttpFoundation\Request;
1718
use Symfony\Component\HttpFoundation\File\UploadedFile;
1819
use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer;
@@ -73,6 +74,19 @@ public function testSubmitDoesNotSaveNullIfNotClearMissing()
7374
$this->form->submit(array(), false);
7475
}
7576

77+
public function testSubmitDoesNotAddExtraFieldForNullValues()
78+
{
79+
$factory = Forms::createFormFactoryBuilder()
80+
->getFormFactory();
81+
82+
$child = $factory->create('file', null, array('auto_initialize' => false));
83+
84+
$this->form->add($child);
85+
$this->form->submit(array('file' => null));
86+
87+
$this->assertCount(0, $this->form->getExtraData());
88+
}
89+
7690
public function testClearMissingFlagIsForwarded()
7791
{
7892
$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.