Skip to content
Merged
Changes from all commits
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
19 changes: 1 addition & 18 deletions src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,21 +357,6 @@ public function getBlockPrefix()
return 'choice';
}

private static function flipRecursive($choices, &$output = array())
{
foreach ($choices as $key => $value) {
if (is_array($value)) {
$output[$key] = array();
self::flipRecursive($value, $output[$key]);
continue;
}

$output[$value] = $key;
}

return $output;
}

/**
* Adds the sub fields for an expanded choice field.
*
Expand Down Expand Up @@ -447,9 +432,7 @@ private function createChoiceListView(ChoiceListInterface $choiceList, array $op
// If no explicit grouping information is given, use the structural
// information from the "choices" option for creating groups
if (!$options['group_by'] && $options['choices']) {
$options['group_by'] = !$options['choices_as_values']
? self::flipRecursive($options['choices'])
: $options['choices'];
$options['group_by'] = $options['choices'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if someone still uses the choices_as_values option?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xabbuh Thanks for the review.

choices_as_values is normalized to true since 3.0 and deprecated in 3.1.

This change is safe.

}

return $this->choiceListFactory->createView(
Expand Down