clear unchecked choice radio boxes even if clear missing is set to false

This commit is contained in:
Christian Flothmann 2021-03-08 18:14:47 +01:00
parent 13055b6d66
commit e7b4851ea0
2 changed files with 16 additions and 0 deletions

View File

@ -141,6 +141,8 @@ class ChoiceType extends AbstractType
$knownValues[$child->getName()] = $value;
unset($unknownValues[$value]);
continue;
} else {
$knownValues[$child->getName()] = null;
}
}
} else {

View File

@ -1287,6 +1287,20 @@ class ChoiceTypeTest extends BaseTypeTest
$this->assertNull($form[4]->getViewData());
}
public function testSubmitSingleExpandedClearMissingFalse()
{
$form = $this->factory->create(self::TESTED_TYPE, 'foo', [
'choices' => [
'foo label' => 'foo',
'bar label' => 'bar',
],
'expanded' => true,
]);
$form->submit('bar', false);
$this->assertSame('bar', $form->getData());
}
public function testSubmitMultipleExpanded()
{
$form = $this->factory->create(static::TESTED_TYPE, null, [