Revert "[Form] refactor RadioListMapper::mapDataToForm()
"
closes #18173.
This reverts commit 8f918e5f84
.
This commit is contained in:
parent
064aedf9e3
commit
71841c737c
@ -38,11 +38,13 @@ class RadioListMapper implements DataMapperInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function mapDataToForms($data, $radios)
|
public function mapDataToForms($choice, $radios)
|
||||||
{
|
{
|
||||||
|
$valueMap = array_flip($this->choiceList->getValuesForChoices(array($choice)));
|
||||||
|
|
||||||
foreach ($radios as $radio) {
|
foreach ($radios as $radio) {
|
||||||
$value = $radio->getConfig()->getOption('value');
|
$value = $radio->getConfig()->getOption('value');
|
||||||
$radio->setData($value === $data ? true : false);
|
$radio->setData(isset($valueMap[$value]) ? true : false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,14 +143,6 @@ class ChoiceType extends AbstractType
|
|||||||
$event->setData(null);
|
$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']) {
|
} elseif ($options['multiple']) {
|
||||||
// <select> tag with "multiple" option
|
// <select> tag with "multiple" option
|
||||||
|
Reference in New Issue
Block a user