F
Filamentβ€’3mo ago
Mike Peters

requiresConfirmation doesn't seem to work on form submit action

hi all! I'm adding a custom form on a custom page but can't seem to add requiresConfirmation() to the form submit. The Form part:
return $form
->schema([
Select::make('tags')
->options($tags ? array_combine($tags, $tags) : [])
->required()
->minItems(1)
->multiple()
->searchable()
])
->statePath('clearCacheFormData');
return $form
->schema([
Select::make('tags')
->options($tags ? array_combine($tags, $tags) : [])
->required()
->minItems(1)
->multiple()
->searchable()
])
->statePath('clearCacheFormData');
The blade;
<x-filament-panels::page>

<x-filament::section>
<x-slot name="heading">
Cache legen
</x-slot>

<form wire:submit="clearCache">
<div class="mb-4">
{{ $this->clearCacheForm }}
</div>

<x-filament-panels::form.actions :actions="[$this->getClearCacheSaveAction()]"/>
</form>
</x-filament::section>
<x-filament-panels::page>

<x-filament::section>
<x-slot name="heading">
Cache legen
</x-slot>

<form wire:submit="clearCache">
<div class="mb-4">
{{ $this->clearCacheForm }}
</div>

<x-filament-panels::form.actions :actions="[$this->getClearCacheSaveAction()]"/>
</form>
</x-filament::section>
The action method;
public function getClearCacheSaveAction(): Action
{
return Action::make('save')
->label('Geselecteerde caches legen')
->requiresConfirmation()
->submit('clearCache');
}
public function getClearCacheSaveAction(): Action
{
return Action::make('save')
->label('Geselecteerde caches legen')
->requiresConfirmation()
->submit('clearCache');
}
- Why is the requiresConfirmation not firing? - Do you see general improvements in this custom form approach? Thanks!!
5 Replies
LeandroFerreira
LeandroFerreiraβ€’3mo ago
rename Action::make('save') to Action::make('getClearCacheSave')
Mike Peters
Mike PetersOPβ€’3mo ago
I'm using the filament page component, I believe it's already there. Adding the thing in the view didn't make a difference. Thanks though! what does getClearCacheSave refer to? Adding this didn't make a difference, but thanks πŸ™‚
LeandroFerreira
LeandroFerreiraβ€’3mo ago
remove submit and add ->action(fn () => $this->clearCache())
Mike Peters
Mike PetersOPβ€’3mo ago
Thanks for the suggestion Leandro!, will try this tomorrow and get back to you on it here @Leandro Ferreira the trick was to not use ->submit('clearCache'), but instead use ->action(). So you were absolutely right πŸ™‚ This combined with the lack of the <x-filament-actions::modals /> in the view together now made it work. Thanks for the help

Did you find this page helpful?