I tried to use a hidden() function in custom filters but it did not work. The function was using a closure that references the value of another custom filter to determine the binary of either true or false.
Steps to reproduce
Filter::make('affiliatable_type')->form([
Select::make('affiliate_type')
->label('Filter by Affiliation')
->reactive()
->afterStateUpdated(function (Closure $set, $state) {
$set('affiliateType', $state);
})
->options([
'County' => 'County',
'NGO' => 'NGO',
'Institution' => 'Institution',
]),
])->query(
function (Builder $query, array $data): Builder {
return $this->filterByAffiliateType($query, $data);
}
),
Filter::make('county')
->hidden(fn(Closure $get) => $get('affiliate_type') !== "County") //This line has a closure that references the first field 👆
->form([
Select::make('affiliation_id')
->label('Select County')
->options(County::all()->pluck('name', 'id')->toArray()),
])->query(
function (Builder $query, array $data): Builder {
return $this->filterByAffiliation($query, $data);
}
),
Package
filament/tables
Package Version
v2.9.17
Laravel Version
v8.82.0
Livewire Version
v2.10.1
PHP Version
PHP 8.0.12
Bug description
I tried to use a hidden() function in custom filters but it did not work. The function was using a closure that references the value of another custom filter to determine the binary of either true or false.
Steps to reproduce
Relevant log output
No response