Clear Button in custom form
I try to use a "clear" Button in a custom form
The create Button works, but the clear buton does not.
protected function getFormActions(): array
{
return [
Action::make('create')
->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
->submit('create'),
Action::make('clear')
->action(function (Set $set) {
$set('data.name', '',);
$set('name', '');
$this->form->fill();
})
];
}protected function getFormActions(): array
{
return [
Action::make('create')
->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
->submit('create'),
Action::make('clear')
->action(function (Set $set) {
$set('data.name', '',);
$set('name', '');
$this->form->fill();
})
];
}The create Button works, but the clear buton does not.
Solution
try
Action::make('clear')
->action('clear')Action::make('clear')
->action('clear')public function clear(): void
{
$this->form->fill();
}public function clear(): void
{
$this->form->fill();
}