FilamentF
Filament5mo 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...
}
Was this page helpful?