How can I access custom page's filters at the custom widget?
I have added "use HasFiltersAction;" and a header filter action at the custom page:
FilterAction::make()
->form([
DatePicker::make('start_date'),
DatePicker::make('end_date'),
]),
I have also added the "use InteractsWithPageFilters;" at the custom Table Widget.
Filters are shown but even when I apply filters, $this->fiilters is always null in the widget class.
Solution:Jump to solution
public function getWidgetData(): array
{
return [
'filters' => $this->filters,
'record' => $this->getRecord(),...
3 Replies
I see that custom pages blade does not include "...(property_exists($this, 'filters') ? ['filters' => $this->filters] : []),
". That would be a good addition for next releases.
For now, I added a getWidget function on the custom page with:
Solution
public function getWidgetData(): array
{
return [
'filters' => $this->filters,
'record' => $this->getRecord(),
];
}
and it worked.