8000 clear unchecked choice radio boxes even if clear missing is set to false · symfony/symfony@e7b4851 · GitHub
[go: up one dir, main page]

Skip to content

Commit e7b4851

Browse files
committed
clear unchecked choice radio boxes even if clear missing is set to false
1 parent 13055b6 commit e7b4851

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
141141
$knownValues[$child->getName()] = $value;
142142
unset($unknownValues[$value]);
143143
continue;
144+
} else {
145+
$knownValues[$child->getName()] = null;
144146
}
145147
}
146148
} else {

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,20 @@ public function testSubmitSingleExpandedObjectChoices()
12871287
$this->assertNull($form[4]->getViewData());
12881288
}
12891289

1290+
public function testSubmitSingleExpandedClearMissingFalse()
1291+
{
1292+
$form = $this->factory->create(self::TESTED_TYPE, 'foo', [
1293+
'choices' => [
1294+
'foo label' => 'foo',
1295+
'bar label' => 'bar',
1296+
],
1297+
'expanded' => true,
1298+
]);
1299+
$form->submit('bar', false);
1300+
1301+
$this->assertSame('bar', $form->getData());
1302+
}
1303+
12901304
public function testSubmitMultipleExpanded()
12911305
{
12921306
$form = $this->factory->create(static::TESTED_TYPE, null, [

0 commit comments

Comments
 (0)
0