F
Filament3mo ago
Asmit

Help: Filter Reset Action

I’m building a custom Filament page where I’m not using a table, but I added a FilterAction to handle filtering. It’s working, but I’m struggling to add a reset button to clear the filters from the modal form.
public function filterAction()
{
return FilterAction::make('filter')
->slideOver(false)
->form([
TextInput::make('title')
->live()
->label('Search'),
Select::make('status')
->label('Status')
->options(DocumentStatus::class)
->placeholder('All Statuses')
->searchable()
->preload(),
]);
}
public function filterAction()
{
return FilterAction::make('filter')
->slideOver(false)
->form([
TextInput::make('title')
->live()
->label('Search'),
Select::make('status')
->label('Status')
->options(DocumentStatus::class)
->placeholder('All Statuses')
->searchable()
->preload(),
]);
}
In my Blade view, I render it like:
{{ $this->filterAction }}
{{ $this->filterAction }}
How can I add a reset/clear action to this filter modal? Any help would be appreciated!
Solution:
Suer, @Dennis Koch , For now, ```php ->extraModalFooterActions(function () {...
Jump to solution
6 Replies
Dennis Koch
Dennis Koch3mo ago
I guess you could add it via the modalFooterAction()
Asmit
AsmitOP3mo ago
Thanks for reply @Dennis Koch How can I reset that filter form with this action
public function filterAction()
{
return FilterAction::make('filter')
->slideOver(false)
->form([
TextInput::make('title')
->live()
->label('Search'),
Select::make('status')
->label('Status')
->options(DocumentStatus::class)
->placeholder('All Statuses')
->searchable()
->preload(),
])
->extraModalFooterActions(function () {
return [
Action::make('reset')
->label('Reset')
->color('secondary')
->action(function() {
// How Can I reset the filters from here?
}),
];
});
}
public function filterAction()
{
return FilterAction::make('filter')
->slideOver(false)
->form([
TextInput::make('title')
->live()
->label('Search'),
Select::make('status')
->label('Status')
->options(DocumentStatus::class)
->placeholder('All Statuses')
->searchable()
->preload(),
])
->extraModalFooterActions(function () {
return [
Action::make('reset')
->label('Reset')
->color('secondary')
->action(function() {
// How Can I reset the filters from here?
}),
];
});
}
Dennis Koch
Dennis Koch3mo ago
I don't have the exact code but I think something like this:
->action(fn ($action) => $action->form->fill([])
->action(fn ($action) => $action->form->fill([])
Asmit
AsmitOP3mo ago
I tried this approach, but it show this
Cannot access protected property Filament\Actions\Action::$form
Cannot access protected property Filament\Actions\Action::$form
Is there any other possible solution you know about it ?
Dennis Koch
Dennis Koch3mo ago
There's probably a method for it then. Try checking the source code.
Solution
Asmit
Asmit3mo ago
Suer, @Dennis Koch , For now,
->extraModalFooterActions(function () {
return [
Action::make('reset')
->label('Reset')
->color('secondary')
->icon('heroicon-o-x-circle')
->action(function () {
// reset data.
$this->reset('property');
$this->replaceMountedAction('cancel');
}),
];
})
->extraModalFooterActions(function () {
return [
Action::make('reset')
->label('Reset')
->color('secondary')
->icon('heroicon-o-x-circle')
->action(function () {
// reset data.
$this->reset('property');
$this->replaceMountedAction('cancel');
}),
];
})
this solution work for me

Did you find this page helpful?