filter inside liveware in v3 - how to get filter state?
in liveware how to design a filter and get its state ?
i have designed a filter inside liveware in filament-v2 and i was getting the state also inside getTableQuery() by using getTableFilters function (provided below)
$month_selected = $this->getTableFilterState("attendance_month")["value"];
but after upgrading to v3 i am not getting filter state .
to check i have provided some customized code like below inside filters of table in liveware .
SelectFilter::make('attendance_month')
->options([
'January' => 'January',
'February' => 'February',
'March' => 'March',
]),
and then inside getTablequery function i have provide below code
$month_selected = $this->table->getFilters();
after it when i tried to check dump($month_selected);
i am getting below result instead of specific optioin which i have choosen.
"attendance_month" => Filament\Tables\Filters\SelectFilter {#3379 ▶}
if anyone knows how to fix this , please assist me further .
5 Replies
Try
dd($this->tableFilters)
@Patrick Boivin thank you for your response, I experienced the same problem. likewise attempted dd($this->tableFilters), which returns null.
This is what I have used inside a table widget.
this is a bit different, can you start a new post in #❓┊help ?
yeah sure
thank you but i am getting null . actually i want to know how to get the exact filter state of a table which is inside a widget and extends TableWidget
i am trying to get the filter value inside getTableQuery(): Builder, which is inside a widget and extends TableWidget .so i am trying to fetch the filter value by using $this->tableFilters['month']['value'] then initially i am getting null instead of default date .
then if i am selecting any other month then i am getting value of previous selected one .
how to fix the issue and get the filter value of current selected value rather than previous selected value ,
please guide me .