ยฉ 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filamentโ€ข3y agoโ€ข
22 replies
Husky110

Displaying a modal after action has been performed

Hi - I want to create a table action (like add it on each row) where a user clicks on a button, it performs an action (connection-check in this case) which returns either true or false. Afterwards I want to see a modal with either "success" or "failure". Now from what I get so far, I can create modals BEFORE an action has been performed (like confirmation modals or form-modals), but how do I do that AFTERWARDS? I could do the workarround by opening a modal, adding a button and update said modal, but that is not elegant enough for me. Is there a way to do it like "click button" -> "perform action" -> "show modal with content concering the action-result"?
Thanks in advance. ๐Ÿ™‚
Solution
Okay - here is what I ended up with:
Tables\Actions\Action::make('checkConnection')
                    ->label('Verbindung prรผfen')
                    ->button()
                    ->action(
                        fn($record) =>
                        Notification::make('checkCon')
                            ->body(function () use ($record){
                                try{
                                    return MyClass::myAction() ? 'Erfolgreich' : 'Fehlgeschlagen';
                                } catch (\Exception){
                                    return 'Fehler';
                                }
                            })
                            ->persistent()
                            ->send()
                    ),
Tables\Actions\Action::make('checkConnection')
                    ->label('Verbindung prรผfen')
                    ->button()
                    ->action(
                        fn($record) =>
                        Notification::make('checkCon')
                            ->body(function () use ($record){
                                try{
                                    return MyClass::myAction() ? 'Erfolgreich' : 'Fehlgeschlagen';
                                } catch (\Exception){
                                    return 'Fehler';
                                }
                            })
                            ->persistent()
                            ->send()
                    ),

Thanks @toeknee and @ZedoX. ๐Ÿ™‚
Jump to solution
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

Action in custom modal content: Update modal content after action performed?
FilamentFFilament / โ“โ”Šhelp
2y ago
Refresh a modal after an extra footer action is performed?
FilamentFFilament / โ“โ”Šhelp
2y ago
Clipboard contents after action has been clicked
FilamentFFilament / โ“โ”Šhelp
12mo ago
Refresh Table after performed action in Widget
FilamentFFilament / โ“โ”Šhelp
2y ago