Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Form] fixed BC break with pre selection of choices with ChoiceType and its children #18180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 28, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Revert "[Form] refactor RadioListMapper::mapDataToForm()"
closes #18173.

This reverts commit 8f918e5.
  • Loading branch information
HeahDude committed Apr 9, 2016
commit 71841c737cbda8aedf450d5b72ed5de4a70132f4
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ public function __construct(ChoiceListInterface $choiceList)
/**
* {@inheritdoc}
*/
public function mapDataToForms($data, $radios)
public function mapDataToForms($choice, $radios)
{
$valueMap = array_flip($this->choiceList->getValuesForChoices(array($choice)));

foreach ($radios as $radio) {
$value = $radio->getConfig()->getOption('value');
$radio->setData($value === $data ? true : false);
$radio->setData(isset($valueMap[$value]) ? true : false);
}
}

Expand Down
8 changes: 0 additions & 8 deletions 8 src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$event->setData(null);
}
});
// For radio lists, pre selection of the choice needs to pre set data
// with the string value so it can be matched in
// {@link \Symfony\Component\Form\Extension\Core\DataMapper\RadioListMapper::mapDataToForms()}
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$choiceList = $event->getForm()->getConfig()->getOption('choice_list');
$value = current($choiceList->getValuesForChoices(array($event->getData())));
$event->setData((string) $value);
});
}
} elseif ($options['multiple']) {
// <select> tag with "multiple" option
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.