Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2807562

Browse files
committed
Handle conflict in DefaultChoiceListFactory
2 parents 99f5757 + f3bfc19 commit 2807562

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,17 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
6565
if ($list instanceof LegacyChoiceListAdapter && empty($preferredChoices)
6666
&& null === $label && null === $index && null === $groupBy && null === $attr && null === $labelAttr) {
6767
$mapToNonLegacyChoiceView = function (LegacyChoiceView $choiceView) {
68-
return new ChoiceView($choiceView->data, $choiceView->value, $choiceView->label);
68+
$choiceView = new ChoiceView($choiceView->data, $choiceView->value, $choiceView->label);
6969
};
7070

7171
$adaptedList = $list->getAdaptedList();
7272

73-
return new ChoiceListView(
74-
array_map($mapToNonLegacyChoiceView, $adaptedList->getRemainingViews()),
75-
array_map($mapToNonLegacyChoiceView, $adaptedList->getPreferredViews())
76-
);
73+
$remainingViews = $adaptedList->getRemainingViews();
74+
$preferredViews = $adaptedList->getPreferredViews();
75+
array_walk_recursive($remainingViews, $mapToNonLegacyChoiceView);
76+
array_walk_recursive($preferredViews, $mapToNonLegacyChoiceView);
77+
78+
return new ChoiceListView($remainingViews, $preferredViews);
7779
}
7880

7981
$preferredViews = array();

0 commit comments

Comments
 (0)