FilamentF
Filament2y ago
Koda

Clear Button in custom form

I try to use a "clear" Button in a custom form

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')


public function clear(): void
{
    $this->form->fill();
}
Was this page helpful?