F
Filament3mo ago
CamKem

Adding a confirmation dialog to makeModalSubmitAction

Hi, I am trying to add a slideover modal form, where I have 2 submit actions, with different conditional logic. I currently have a wire:confirm on the submit action that I would like to move to a filament native confirmation, no matter what I tried I could not get it to work. Any help is appreciated.
return $action
->slideOver()
->mutateFormDataUsing(function (array $data): array {
// mutate here
return collect($data)->except(['users', 'files', 'disk'])->toArray();
})
->after(function (?Incident $record, Page $livewire): void {
// refresh and notify
})
->successNotificationTitle($notification)
->modalSubmitAction(false)
->modalFooterActionsAlignment('right')
->extraModalFooterActions(fn (MountableAction $action, ?Incident $record): array => [
$action->makeModalSubmitAction('saveAndClose', arguments: ['action' => 'saveAndClose'])
->extraAttributes([
'wire:confirm' => 'Are you sure you want to close the incident? This action cannot be undone.',
]),
$action->makeModalSubmitAction('saveAs', arguments: ['action' => 'saveAs'])
->disabled(static fn () => $record?->status === IncidentStatus::Closed)
->icon('heroicon-s-document-text'),
$action->makeModalAction('cancel')
->label('Cancel')
->color('gray')
->icon('heroicon-s-x-mark'),
])
// more logic on beforeFormValided, etc...
}
return $action
->slideOver()
->mutateFormDataUsing(function (array $data): array {
// mutate here
return collect($data)->except(['users', 'files', 'disk'])->toArray();
})
->after(function (?Incident $record, Page $livewire): void {
// refresh and notify
})
->successNotificationTitle($notification)
->modalSubmitAction(false)
->modalFooterActionsAlignment('right')
->extraModalFooterActions(fn (MountableAction $action, ?Incident $record): array => [
$action->makeModalSubmitAction('saveAndClose', arguments: ['action' => 'saveAndClose'])
->extraAttributes([
'wire:confirm' => 'Are you sure you want to close the incident? This action cannot be undone.',
]),
$action->makeModalSubmitAction('saveAs', arguments: ['action' => 'saveAs'])
->disabled(static fn () => $record?->status === IncidentStatus::Closed)
->icon('heroicon-s-document-text'),
$action->makeModalAction('cancel')
->label('Cancel')
->color('gray')
->icon('heroicon-s-x-mark'),
])
// more logic on beforeFormValided, etc...
}
3 Replies
Arnold Schwarzenegger
I think you're missing the requiresConfirmation() part Also, you might want the modalFooterActions() method instead of extraModalFooterActions() if you're overwritting everything
LeandroFerreira
LeandroFerreira2mo ago
GitHub
Adding requiresConfirmation modal actions when using multiple makeM...
Package Form builder Package Version 3.3.4 How can we help you? I have modal slideover that is rendering a form, which has 2 submit actions, with different conditional logic. I currently have a wir...
CamKem
CamKemOP2mo ago
Thanks for the response, can you give me an example of how i'd use replacing the mounted action here to use a filament native confirmation? Appreciate the assistance!

Did you find this page helpful?