Skip to content

Fix choice filter error when loading mix of grouped and non-grouped choices #46576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

BreyndotEchse
Copy link
Contributor

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
License MIT

How to reproduce this bug:

$choiceType = $builder->create('test', ChoiceType::class, [
    'choice_loader' => new CallbackChoiceLoader(fn() => [
        'Foo',
        'Optgroup' => [
            'Bar',
            'Baz',
        ],
    ]),
    'choice_filter' => fn() => true,
]);
$choiceType->getForm()->createView();

TypeError:

Argument 1 passed to Symfony\Component\Form\ChoiceList\ArrayChoiceList::getChoicesForValues() must be of the type array, string given, called in ~/symfony/form/ChoiceList/Loader/FilterChoiceLoaderDecorator.php on line 39

Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

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

Thanks for that fix

@BreyndotEchse BreyndotEchse force-pushed the bugfix/filter-choice-loader-grouped-and-non-grouped-options branch from dec633f to 24c65bf Compare June 7, 2022 10:07
@fabpot
Copy link
Member

fabpot commented Jun 9, 2022

Thank you @BreyndotEchse.

@fabpot fabpot merged commit 5346467 into symfony:5.4 Jun 9, 2022
@fabpot fabpot mentioned this pull request Jun 9, 2022
This was referenced Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants