-
Notifications
You must be signed in to change notification settings - Fork 58
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
EmbeddedList, on empty many-to-many attributes, ignore filters #152
Comments
Hi @McLone ! Empty arrays are ignored by dynamic filtered queries. This is a known limitation, and I prefer not to try to work around this. Which case are trying to solve. Can't you test if your value list is not empty before generating the URL ? |
@alterphp I have the following configuration: entities:
User:
class: App\Entity\User
show:
fields:
- email
- { property: 'cars', label: 'Cars', type: embedded_list } with cars having a many-to-many relation. When I'm in the "show" of a user with no car assigned, I expect to see an "empty result", but I see all cars of my database. |
@McLone thanks for this, I just decorated this service |
I guess I am experiencing the same problem here. I also have a
It shows all questions at all times. My expectation was that it actually only shows the ones actually related to |
Hi!
It looks like the url generated for the subquery drops the "filters" attribute on Generator/UrlGenerator.php:275 in symfony/routing v4.2.10 (but I guess it should impact all versions) :
$extra does have a key 'filters' with an array 'entity.id' => [], but http_build_query seems to not like empty array and does'nt put filters in its query (see https://stackoverflow.com/questions/2930592/http-build-query-ignores-the-key-if-the-value-is-an-empty-array-how-is-this-not).
A quick and dirty fix would be to replace, in src/Helper/EmbeddedListHelper.php:144 (v2.1.6) :
by
... but only works if we're sure to never have entities with "0" id.
Thanks to all contributor of this bundle 👍
The text was updated successfully, but these errors were encountered: