Skip to content

Commit

Permalink
clear unchecked choice radio boxes even if clear missing is set to false
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Mar 8, 2021
1 parent 13055b6 commit e7b4851
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$knownValues[$child->getName()] = $value;
unset($unknownValues[$value]);
continue;
} else {
$knownValues[$child->getName()] = null;
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,20 @@ public function testSubmitSingleExpandedObjectChoices()
$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, [
Expand Down

0 comments on commit e7b4851

Please sign in to comment.