Skip to content

Commit

Permalink
bug #40417 [Form] clear unchecked choice radio boxes even if clear mi…
Browse files Browse the repository at this point in the history
…ssing is set to false (xabbuh)

This PR was merged into the 4.4 branch.

Discussion
----------

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

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #16802
| License       | MIT
| Doc PR        |

Commits
-------

e7b4851 clear unchecked choice radio boxes even if clear missing is set to false
  • Loading branch information
fabpot committed Mar 9, 2021
2 parents 72c6489 + e7b4851 commit 2fb98c8
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
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
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 2fb98c8

Please sign in to comment.