F
Filament3mo 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
Sidem3mo ago
what the difference between value and Filter_value ?
toeknee
toeknee3mo 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]=tony@google.com
Sidem
Sidem3mo ago
and what does it look like on the code side?
toeknee
toeknee3mo ago
Just build the filters as normal, no need to code anything else in.
Sidem
Sidem3mo 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
toeknee3mo ago
yea h
Sidem
Sidem3mo 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
toeknee3mo 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
Sidem3mo ago
nop my url didn't change, because i run my project with npm and artisan (in local)
toeknee
toeknee3mo ago
You run a filament app with npm?
Sidem
Sidem3mo 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
toeknee3mo ago
Will that's how it works.
Sidem
Sidem3mo ago
anyway my url didn't change when i put my filter, do you have any idee ?
toeknee
toeknee3mo ago
No, I've shown it above how it works. PRovide all your code if it's not working.