How to route to a page with a given filter?
Currently I have a resource with a relation resource. Those relation resource records should get a url to another page with there given property as a filter.
So, in my
ExampleRelationManager
I have this:
This is not working. I assume there is a correct way to give filters to the ::getUrl()
method, just like given a route parameter.
For the record, the URL to end up with, should be: https://example.local/...?tableFilters[unit][reservable][code]=UN100000
Help?9 Replies
Well as I see it you have 2 simple options. Either pass the name "index" as first paremeter or use named arguments:
Or
š¤
@dissto I'm sorry for being unclear. I know how to add the parameters, it's just not working. I end up with a URL like:
https://example.local/...?tableFilters%5Bunit%5D%5Breservable%5D%5Bcode%5D=xxx
That gets combined with the already active filters, and I end up with duplicate filters...Well the url is encoded, thats to be expected?!
Can you use a url for testing?
Not sure if it should encode.. I hoped not. Let me try your example
@dissto Same thing.. 0 difference
The tableFilters is now part of the url and not the filter part.. thats why Filament doesn't change it.. and keeps adding
Don't get me wrong, it applies the filter, but whenever I add another or change the existing one to another value, the filter is being re-applied to the whole url, ending up with:
https://example.local/....?tableFilters%5Bunit%5D%5Breservable%5D%5Bcode%5D=UN100000&tableFilters[unit][reservable][code]=UN100001
Laravel encodes the [ ]
... since it's not a part of:
I see what you mean now
Well maybe constructing the url yourself. Not sure if there is an easier way. Or even a way to not encode the route parameters, as this seems to be causing the issue. š¤
Found it, it's a Filament bug. Square brackets
[ ]
should always be encoded, since not all browser recognizes them. The are not part of the allowed characters list. So Filament should always encode these, but they are not. Hence my problem: Laravel encodes them, Filament does not > duplicate values!
Let me try your workaround..
@dissto 1 question though, whats the difference between using ->url()
and ->action()
with a redirect?Url is just a link...the action is an actual redirect. But you can use the same with an action..i was just using url in this case š
workaround works! thanks!
I'll report the bug š
Just for documentation sake, here's full the (workaround) solution:
GitHub
Filament does not encode square brackets in the URL by default Ā· Is...
Package filament/filament Package Version v3.2.68 Laravel Version v11.10 Livewire Version v3.5.0 PHP Version PHP 8.2 Problem description Filament does not encode square brackets [ ] in the URL by d...