F
Filament6mo ago
dyo

Create dependancy select filter

Can anyone help me to solve the above problem? I want the selectfilter options dependance to other selectfilter value..
2 Replies
Antoni
Antoni6mo ago
not sure for the built in Filament\Tables\Filters\SelectFilter but you can with the custom filter https://filamentphp.com/docs/3.x/tables/filters/custom
Filter::make('xxxx')
->form([
Select::make('user_id')
->options([
1 => 'a',
2 => 'b'
])
->reactive(),
Select::make('another_id')
->options(fn ($get) => Model::whereIn('user_id', $get('user_id'))->pluck('name', 'id'))
])
->query(function (Builder $query, array $data): Builder {
// your filter query
})
Filter::make('xxxx')
->form([
Select::make('user_id')
->options([
1 => 'a',
2 => 'b'
])
->reactive(),
Select::make('another_id')
->options(fn ($get) => Model::whereIn('user_id', $get('user_id'))->pluck('name', 'id'))
])
->query(function (Builder $query, array $data): Builder {
// your filter query
})
dyo
dyo6mo ago
thanks for your suggestion. i'll try it..