F
Filament2y ago
dyo

reactive method in selectfilter

How can I use reactive method in selectfilter class?
11 Replies
Vp
Vp2y ago
Filament
Fields - Form Builder - Filament
The elegant TALL stack form builder for Laravel artisans.
dyo
dyoOP2y ago
Filament\Tables\Filters\SelectFilter::reactive does not exist i got that error when i tried to use reactive method
Vp
Vp2y ago
Then they hide it for some reason.. you can create your own filter and use FormSelect https://filamentphp.com/docs/2.x/tables/filters#custom-filter-forms
Filament
Filters - Table Builder - Filament
The elegant TALL stack table builder for Laravel artisans.
Dan Harrin
Dan Harrin2y ago
all filter fields are reactive() by default
dyo
dyoOP2y ago
how can I get the variable? i got error the error when i called $get as the parameter in other component class method function: Unable to resolve dependency [Parameter #0 [ <required> $get ]]
Dan Harrin
Dan Harrin2y ago
please explain what you’re trying to achieve
dyo
dyoOP2y ago
i want a selectfilter component dependant to another.. in my case,
SelectFilter::make('lembagaId')->label('Lembaga')
->visible(fn () => auth()->user()->id_cms_privileges == 1)
->options(fn () => Lembaga::all()->pluck('nama_lembaga', 'id')),

SelectFilter::make('rekening_id')->options(function ($get) {
$rekening = Rekening::when($get('lembagaId'), function ($query) {
return $query->where('lembaga_id', $get('lembagaId'));
})->orderby('nama_rekening')->all();
// when(auth()->user()->id_cms_privileges == 1, function ($query) {
// return $query->where('lembaga_id', auth()->user()->lembaga_id);
// })->
SelectFilter::make('lembagaId')->label('Lembaga')
->visible(fn () => auth()->user()->id_cms_privileges == 1)
->options(fn () => Lembaga::all()->pluck('nama_lembaga', 'id')),

SelectFilter::make('rekening_id')->options(function ($get) {
$rekening = Rekening::when($get('lembagaId'), function ($query) {
return $query->where('lembaga_id', $get('lembagaId'));
})->orderby('nama_rekening')->all();
// when(auth()->user()->id_cms_privileges == 1, function ($query) {
// return $query->where('lembaga_id', auth()->user()->lembaga_id);
// })->
Dan Harrin
Dan Harrin2y ago
try using Filter instead of SelectFilter then putting both Select components in a custom form() then you can use $get as normal
dyo
dyoOP2y ago
what did you mean by this?
Dan Harrin
Dan Harrin2y ago
check the docs for “filter forms”
dyo
dyoOP2y ago
hmm okey.. i got it.. thanks..
Want results from more Discord servers?
Add your server