8000 ChoiceType flattens nested Choices when expanded · DavidChristmann/symfony@7a8e1b3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7a8e1b3

Browse files
committed
ChoiceType flattens nested Choices when expanded
1 parent 82b0b37 commit 7a8e1b3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,19 @@ public function buildForm(FormBuilder $builder, array $options)
4141

4242
if ($options['expanded']) {
4343
// Load choices already if expanded
44-
$options['choices'] = $options['choice_list']->getChoices();
44+
$choices = $options['choice_list']->getChoices();
45+
46+
// Flatten choices
47+
$flattened = array();
48+
foreach ($choices as $value => $choice) {
49+
if (is_array($choice)) {
50+
$flattened = array_replace($flattened, $choice);
51+
} else {
52+
$flattened[$value] = $choice;
53+
}
54+
}
55+
56+
$options['choices'] = $flattened;
4557

4658
foreach ($options['choices'] as $choice => $value) {
4759
if ($options['multiple']) {

0 commit comments

Comments
 (0)
0