Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

Question: "not in" filter in many to many relation #293

Open
dlopeza opened this issue May 23, 2018 · 1 comment
Open

Question: "not in" filter in many to many relation #293

dlopeza opened this issue May 23, 2018 · 1 comment

Comments

@dlopeza
Copy link

dlopeza commented May 23, 2018

I´m using LexikFormFilter to make some filters. I have a ManyToMany relation between entities 'Person' and 'Language', and I want to be able to filter for Persons that don´t speak an specific language.

I think I have to use 'apply_filter' but I can´t get it working.

Thanks in advance.

@spackmat
Copy link
Contributor

spackmat commented Mar 4, 2022

Hey @dlopeza I have a working solution posted here: https://stackoverflow.com/questions/39894794/how-to-add-additional-options-on-symfony-entitytype-form-widget/71351751#71351751

As of the EntityFilterType does not allow additional choices, I have to go for a ChoiceFilterType, throw in the actual choices (with an added 'none' choice in front) instead of a QueryBuilder and handle the filter stuff within an apply_filter closure.

Saying that: I would love to see that common usecase (allowing to filter explicitly for relations that are not set) built directly into the bundle, maybe as an own EntityOrNoneFilterType, when adding an allow_explicit_none option to the current EntityFilterType is not suitable. I had a quick look into the DoctrineORMSubscriber that seemingly could be enabled to handle an extra 'none' value, and I assume that the other Subscribers could be enabled, too. But as it relies on Symfony's EntityType form type, an extra 'none' choice seems to be not possible here. I'm not that deep into this bundle's codebase so please correct me if I'm wrong.

Question to the maintainers (seemingly just @Spike31 at the moment): Do you see this feature as valuable enough to implement that? I can offer some help if needed.

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

No branches or pull requests

2 participants