Skip to content
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

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

Conversation

BreyndotEchse
Copy link
Contributor

@BreyndotEchse BreyndotEchse commented Jun 3, 2022

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

Thanks for that fix

@BreyndotEchse BreyndotEchse force-pushed the bugfix/filter-choice-loader-grouped-and-non-grouped-options branch from dec633f to 24c65bf Compare Jun 7, 2022
fabpot
fabpot approved these changes Jun 9, 2022
@fabpot
Copy link
Member

fabpot commented Jun 9, 2022

Thank you @BreyndotEchse.

@fabpot fabpot merged commit 5346467 into symfony:5.4 Jun 9, 2022
7 of 10 checks passed
@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.

None yet

4 participants