F
Filament14mo ago
sotjj

Access filters in action

In a livewire component that implements Tables\Contracts\HasTable, how can I access the active filters from getTableFilters() within the getActions() method of a filament page? If I am missing where this is already described in the docs, please provide a link. Thanks. (I apologize if this has been answered already, I have been searching but haven't found anything.)
5 Replies
binaryruel
binaryruel14mo ago
There's a filters property on the $livewire object.
Patrick Boivin
Patrick Boivin14mo ago
@sotjj I think $this->tableFilters contain the active filters (or null if none are active)
sotjj
sotjj14mo ago
Thank you. I’ll try it in a little bit. I think I tried something similar, but I might have just had the wrong property because I think I had $this->filters. Although this works within the livewire component, the problem I am having is accessing this from a page action. In other words, $this->tableFilters works within the getTableActions() within the livewire component.
However, on my filament custom page, using getActions() to make a button at the top of the page, how can I get this value from the livewire component? Will I need to emit an event or is there something built into filament so I can get to this?
awcodes
awcodes14mo ago
You should have access to $livewire in the action() callback. Ie action(function ($livewire) {})
sotjj
sotjj14mo ago
Great, thank you. Trying now. Thanks for the help, all. I ended up going a different direction for now. I need to do some more work on my livewire knowledge base, in general. 🤪 rather than trying to get the filters from a table, I just made a form instead. Probably cleaner, anyway.