Closed
Description
Because the buildView
function does the following, any nested choices
are incorrectly intersected by their group rather than the true choices:
$choices = $form->getAttribute('choice_list')->getChoices();
$preferred = array_flip($form->getAttribute('preferred_choices'));
$view
...
->set('preferred_choices', array_intersect_key($choices, $preferred))
->set('choices', array_diff_key($choices, $preferred))
How would you prefer this to be resolved?
A couple of new helper functions like:
ChoiceType#getPreferredChoices($choices, $preferred)
andChoiceType#getRemainingChoices($choices, $preferred)
Or modify ChoiceList
to support these convenience methods:
ChoiceList#getPreferredChoices($preferred)
andChoiceList#getRemainingChoices($preferred)
Suggestions welcome!