Skip to content

Fix ChoiceType filter with multiple/expanded options (2nd attempt) #213

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

maciazek
Copy link

Hi @Kreyu,

Here is my second attempt to fix #151. After some more digging I was able to solve this (I hope so) by skipping children with checked variable set (in src/Util/FormUtil.php). Probably not ideal, but maybe a good starting point?
I also included fix for using other filters when multiple/expanded filter is present (in src/Filter/FilterData.php) and fix for clearing multiple/expanded filter (in src/Filter/FilterClearUrlGenerator.php). Sorry for trashy commit history.

What do you think about this? If this is not the kind of fix you would like to merge, maybe you have some other idea to solve this?
Today I tested it at my workplace and it looked fine, but of course it needs to be thoroughly tested. @j0r1s could I ask you to test this in your environment?

I also prepared a separate branch in my demo app (branch test/multiple-choices), where these changes can be tested. After checkout, run composer install and php bin/console app:reload-database. Filter with multiple/expanded options can be found in Filters -> Doctrine ORM tab.

If anyone would like to test this PR in their app, it can be done in the following way:

@j0r1s
Copy link

j0r1s commented Apr 29, 2025

@j0r1s could I ask you to test this in your environment?

Sure, thanks for working on this. It’s been quite a blocker for me to use this bundle in a production environment.
I quickly tested your branch on my small reproducer repo, and it does seem to fix the issue.

The only thing that I can spot at a quick glance is that the filter is lost when using the "Items per page" control, but this does not seem related since a column sort would be lost as well.

I'll test it later on a real world complex app.

@maciazek
Copy link
Author

There's at least one issue with this solution: when using other filters (but not the multiple one), empty values of multiple filter are not included in the url query parameters. I'm not sure if this is actually an issue, but I see that other filters' empty values are included in the url.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using a ChoiceType (or EnumType) with multiple / expanded set to true as a filter breaks URL generation
2 participants