F
Filament9mo ago
Sidem

Load page with filter

Hi I would like to know if there is a method to load a filament page with a filter defined according to the link where you click: On a page that lists missions, I need to redirect the user to a list of requests related to the mission they clicked on. If you have an idea, I won't say no, thank you
16 Replies
Sidem
SidemOP9mo ago
what the difference between value and Filter_value ?
toeknee
toeknee9mo ago
[value] is the name of the key, it needs to stay the same. So for example for users: https://mysite.test/mypanel/users?tableFilters[email_address][value][email protected]
Sidem
SidemOP9mo ago
and what does it look like on the code side?
toeknee
toeknee9mo ago
Just build the filters as normal, no need to code anything else in.
Sidem
SidemOP9mo ago
so if my filter is :
SelectFilter::make('email_address')
->label('email')
->relationship('email_user', 'email',
fn ($query) => $query->orderBy('email', 'asc'))
->preload(),
SelectFilter::make('email_address')
->label('email')
->relationship('email_user', 'email',
fn ($query) => $query->orderBy('email', 'asc'))
->preload(),
The adresse_email table is a list of email like : id email 1 hotmail 2 gmail .... The user table is like : id name email_id 1 toto 2 2 tata 1 .... so my url have to be : https://mysite.test/mypanel/users?tableFilters[email_address][email]=hotmail And now i will have a list of user who have a @hotmail
toeknee
toeknee9mo ago
yea h
Sidem
SidemOP9mo ago
Do you know where i can find the documentation for this ? That didn't work even though I did everything you told me
toeknee
toeknee9mo ago
IT's simple, build the filter as normal, then filter. Your page url will now change with the filters in, copy those filters But note, using a select you cannot filter by @hotmail.com you wouild need to filter by the exact value if you want to search and not apply a filter, that's different you would use: ?tableSearch=tony%40hotmail ensuring you have the column as searchable
Sidem
SidemOP9mo ago
nop my url didn't change, because i run my project with npm and artisan (in local)
toeknee
toeknee9mo ago
You run a filament app with npm?
Sidem
SidemOP9mo ago
yes i use "npm run dev" and "php artisan serve" but also i use "npm run build" and "php artisan serve", my url didn't change when i put a filter
toeknee
toeknee9mo ago
Will that's how it works.
Sidem
SidemOP9mo ago
anyway my url didn't change when i put my filter, do you have any idee ?
toeknee
toeknee9mo ago
No, I've shown it above how it works. PRovide all your code if it's not working.
Want results from more Discord servers?
Add your server