Open pille1842 opened 3 years ago
EntityFilter in general is rather basic. What you want can be accomplished with some work, as we use OneToMany/ManyToMany filtering in our app. The most annoying part is fetching possible options, but once you get past that all you need is just
$filter = EntityFilter('something');
$filter->getAsDto()->setApplyCallable([...]);
where you attach your own filtering code along with joins in the apply callable. I'm unsure whether this would be a good fit for the default EntityFilter, but I can sure see it being useful in general, as we already had to deal with something like that a few times.
Hello, we have also observed this issue, but we consider this issue more a bug than a feature. Because the behavior, of the filter, equals not filter, seems wrong. Intuitively the user would imagine, that referring to the example of @pille1842 they filter "Society is not SocA", they don't want any members of SocA to be in the results.
Short description of what this feature will allow to do: The EntityFilter should not just have "is equal to" and "is not equal to", but also "contains" and "does not contain" for ManyToMany associations.
Example of how to use this feature I have two entities, societies and members. A member can be associated with many societies:
Imagine having two societies SocA and SocB. Member MemA is a member of both SocA and SocB. When using the EntityFilter searching for "Society is not SocA", MemA will still be in the results, because the "societies" property of MemA isn't completely equal to "SocA" (since it also contains "SocB"). But this is not what the user would probably expect to happen: If they filter "Society is not SocA", they don't want any members of SocA to be in the results.
The solution, in my view, would be to add the options "contains" / "doesn't contain" to the EntityFilter. I'm not quite clear on the implementation details, but what you would expect when filtering for "doesn't contain SocA" is that any members having SocA in their societies won't be in the results.