Linking Between Table Views with a Filter Value

I am relatively new to Filament. I am wanting to create an action that will link from one Table Resource to another in filament, but I want to pass through a filter value in the link so the 2nd table resource is only showing the records that I want shown based on the filter I pass through. I can't see anywhere in the documentation about this.
Solution:
I think this should work: ```php route('filament.admin.resources.event-survey-sections.index', [ 'tableFilters' => [ 'event_survey_id' => [...
Jump to solution
11 Replies
Patrick Boivin
Patrick Boivin15mo ago
Are are you creating the link from one table to the other?
Dave Mack
Dave MackOP15mo ago
Yes - trying to…
Patrick Boivin
Patrick Boivin15mo ago
Sorry, I meant How are you creating the link, lol
Dave Mack
Dave MackOP15mo ago
Using an Action with a URL - I can create the route, but I cannot add the parameter with the filter value
Patrick Boivin
Patrick Boivin15mo ago
Can you share the code you are trying?
Dave Mack
Dave MackOP15mo ago
Action::make('Show Survey Sections') ->url(fn(EventSurvey $record): string => route('filament.admin.resources.event-survey-sections.index', ['event_survey_id' => $record->id])), The URL I need to end up with is admin/event-survey-sections?tableFilters[event_survey_id][value]=1 which is what I get when I manually filter the data - but I want to be able to create this link from an action in the "Event Survey" table rows...
Solution
Patrick Boivin
Patrick Boivin15mo ago
I think this should work:
route('filament.admin.resources.event-survey-sections.index', [
'tableFilters' => [
'event_survey_id' => [
'value' => $record->id,
],
],
])
route('filament.admin.resources.event-survey-sections.index', [
'tableFilters' => [
'event_survey_id' => [
'value' => $record->id,
],
],
])
Patrick Boivin
Patrick Boivin15mo ago
Or through the resource class:
EventSurveySectionsResource::getUrl('index', [
'tableFilters' => [
'event_survey_id' => [
'value' => $record->id,
],
],
])
EventSurveySectionsResource::getUrl('index', [
'tableFilters' => [
'event_survey_id' => [
'value' => $record->id,
],
],
])
Dave Mack
Dave MackOP15mo ago
You're a legend! i am almost certain that I tried the first option (which I am going to use), however clearly, I had something not hooked up correctly... Thankyou so much for your help...
BuddhaNature
BuddhaNature13mo ago
I tried this, but ended up with an encoded URL that did not cause the trigger to work. Is this solution still working for you all? This is what I get:
/company?tableFilters%5Bcompany%5D%5Bname%5D%5Bvalue%5D=01hfafyrgq166fqr022yrjyyax
/company?tableFilters%5Bcompany%5D%5Bname%5D%5Bvalue%5D=01hfafyrgq166fqr022yrjyyax
Action::make('company')
->url(
fn($record): string => CompanyResource::getUrl(
'index',
[
'tableFilters' => [
'company' => [
'name' => [
'value' => $record->id,
],
],
],
]
)
),
Action::make('company')
->url(
fn($record): string => CompanyResource::getUrl(
'index',
[
'tableFilters' => [
'company' => [
'name' => [
'value' => $record->id,
],
],
],
]
)
),
bernhard
bernhard11mo ago
The encoded url isn't the problem. You should change value to search. This should work So
Action::make('company')
->url(
fn($record): string => CompanyResource::getUrl(
'index',
[
'tableFilters' => [
'company' => [
'name' => [
'search' => $record->id,
],
],
],
]
)
),
Action::make('company')
->url(
fn($record): string => CompanyResource::getUrl(
'index',
[
'tableFilters' => [
'company' => [
'name' => [
'search' => $record->id,
],
],
],
]
)
),
Want results from more Discord servers?
Add your server