8000 update fix · symfony/symfony@ee9dc9b · GitHub
[go: up one dir, main page]

Skip to content

Commit ee9dc9b

Browse files
committed
update fix
1 parent 6ff8ec0 commit ee9dc9b

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/Symfony/Component/Form/Form.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ public function submit($submittedData, $clearMissing = true)
562562

563563
foreach ($this->children as $name => $child) {
564564
$isSubmitted = array_key_exists($name, $submittedData);
565+
$clearMissing = $this->getConfig()->getOption('expanded') ?: $clearMissing;
565566

566567
if ($isSubmitted || $clearMissing) {
567568
$child->submit($isSubmitted ? $submittedData[$name] : null, $clearMissing);
@@ -580,8 +581,6 @@ public function submit($submittedData, $clearMissing = true)
580581
if (method_exists($child, 'getClickedButton') && null !== $child->getClickedButton()) {
581582
$this->clickedButton = $child->getClickedButton();
582583
}
583-
} elseif (!$isSubmitted && !$clearMissing && array_key_exists($name, $submittedData)) {
584-
$child->submit($submittedData[$name], $clearMissing);
585584
}
586585
}
587586

src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,4 +1934,23 @@ public function testSubmitDoesMapChoiceDataIfNotClearMissingWhenExpanded()
19341934

19351935
$this->assertSame(array('foo' => 'baz'), $form->getData());
19361936
}
1937+
1938+
public function testSubmitDoesMapChoiceDataIfNotClearMissingWhenCollapsed()
1939+
{
1940+
$builder = $this->factory->createBuilder('form', array('foo' => 'bar'));
1941+
1942+
$form = $builder->add('foo', 'choice', array(
1943+
'choices' => array(
1944+
'bar' => 'BAR',
1945+
'baz' => 'BAZ',
1946+
),
1947+
))
1948+
->getForm();
1949+
1950+
$this->assertSame(array('foo' => 'bar'), $form->getData());
1951+
1952+
$form->submit(array('foo' => 'baz'), false);
1953+
1954+
$this->assertSame(array('foo' => 'baz'), $form->getData());
1955+
}
19371956
}

0 commit comments

Comments
 (0)
0