© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
7 replies
Anik

opening modal on action button programmatically

https://filamentphp.com/docs/2.x/tables/actions#modals
Hi, is there any method to open to the button modal on page load/mounted
            Action::make('newPromo')
                ->button()
                ->label('Add Promo')
                ->color('primary')
                ->mountUsing(fn (ComponentContainer $form) => $form->fill([
                    'affiliate_id' => $this->affiliate->id,
                ]))
                ->action(function ($data) {
                    $data = array_merge($data,['event_id' => $this->eventId]);
                    $eventPromo = EventPromo::query()->create($data);
                    $this->notify('success', $eventPromo->name.' Promo Created');
                    return redirect()->to(EventsResource::getUrl('promos',['record' => $this->eventId]));

                })
                ->form($this->promoForm())
                ->modalHeading('Add Promo')
                ->modalActions([
                    ModalButtonAction::make('create')
                        ->label('Create')
                        ->submit('callMountedAction')
                        ->color('primary'),

                    ModalButtonAction::make('cancel')
                        ->label('Cancel')
                        ->cancel()
                        ->color('secondary'),
                ])
            //    ->extraAttributes(['isOpen' => true])
            Action::make('newPromo')
                ->button()
                ->label('Add Promo')
                ->color('primary')
                ->mountUsing(fn (ComponentContainer $form) => $form->fill([
                    'affiliate_id' => $this->affiliate->id,
                ]))
                ->action(function ($data) {
                    $data = array_merge($data,['event_id' => $this->eventId]);
                    $eventPromo = EventPromo::query()->create($data);
                    $this->notify('success', $eventPromo->name.' Promo Created');
                    return redirect()->to(EventsResource::getUrl('promos',['record' => $this->eventId]));

                })
                ->form($this->promoForm())
                ->modalHeading('Add Promo')
                ->modalActions([
                    ModalButtonAction::make('create')
                        ->label('Create')
                        ->submit('callMountedAction')
                        ->color('primary'),

                    ModalButtonAction::make('cancel')
                        ->label('Cancel')
                        ->cancel()
                        ->color('secondary'),
                ])
            //    ->extraAttributes(['isOpen' => true])
Filament
Actions - Table Builder - Filament
The elegant TALL stack table builder for Laravel artisans.
Actions - Table Builder - Filament
Solution
Action::make('newPromo')
    ->extraAttributes(['wire:init' => new HtmlString('mountTableAction(\'newPromo\')')])
Action::make('newPromo')
    ->extraAttributes(['wire:init' => new HtmlString('mountTableAction(\'newPromo\')')])
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

Preview action button on modal
FilamentFFilament / ❓┊help
3y ago
Action modal not opening
FilamentFFilament / ❓┊help
3y ago
Bulk Action Button on Modal Submit
FilamentFFilament / ❓┊help
15mo ago