FilamentF
Filament3y ago
Ben

Action modal registered using render hook not trigger the modal

I have Livewire component that had an action modal in it. When I click the trigger button, its not trigger the modal. I checked the network tab, its actually dispatch the close-modal instead of open-modal.

If I put the button somewhere else (page header action, table header action) it works. How can I achieve this? I just wanted to have button trigger of the modal on topbar.

Here are the action snippet

public function addLinkAction(): Actions\Action
{
    return Actions\CreateAction::make("add-link")
        ->label(__('Add Link'))
        ->icon('heroicon-o-plus')
        ->size('lg')
        ->outlined()
        ->modalWidth('xl')
        ->extraAttributes(['class' => 'w-full'])
        ->mutateFormDataUsing(function (array $data): array {
            $data['user_id'] = Filament::auth()->id();

            return $data;
        })
        ->model(Link::class)
        ->after(function (self $livewire, Link $record) {
            $livewire->redirect(route('filament.app.pages.link', ['link' => $record]));
        })
        ->form([
            ... // forms
        ]);
}
Was this page helpful?