© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•9mo ago•
4 replies
TjardoOrtan

How can I conditionally show a confirmation modal during a resource edit form save.

Hello everyone,

I am struggling with this use-case:

What I am trying to do:
When an admin edits a user and removes a language from the "languages" relationship, I want to show a confirmation modal asking:
"Are you sure you want to remove this language from the user?"
If confirmed, proceed with the save. If canceled, return to the form with all current input preserved. If nothing is changed on the submit the warning should not pop up.

What I did:
I looked into using ->modalHidden(fn () => ...) on the action, and also tried to use ->before() on the action to handle conditional logic and show a notification on cancel.

I can't figure out how to intercept the save/update flow and inject a confirmation modal only if a language is removed, while still keeping the form state intact if the user cancels.

I have this in the EditUser.php

protected function getSaveFormAction(): Action
{
if ($this->shouldShowConfirmationModal()) {
return Action::make('save')
->label(('filament-panels::resources/pages/edit-record.form.actions.save.label'))
->action(function () {
$this->save();
})
->modalHeading(
('app.messages.user_language_warning_text'))
->modalWidth(MaxWidth::Medium)
->requiresConfirmation();
} else {
return Action::make('save')
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
->submit('save')
->keyBindings(['mod+s']);
}
}

But that seems to get called before the actual submit.

Anyone has a suggestion or can point me in the right direction?

Cheers, Tjardo
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

How can I make my form action show a confirmation modal?
FilamentFFilament / ❓┊help
2y ago
Edit Resource - Save Form Pop-Up
FilamentFFilament / ❓┊help
3y ago
How would I return a modal form in the Resource Edit Page?
FilamentFFilament / ❓┊help
14mo ago
How can I test a form from a modal? (simple resource)
FilamentFFilament / ❓┊help
2y ago