F
Filament15mo 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
]);
}
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
]);
}
8 Replies
awcodes
awcodes15mo ago
did you add <x-filament-actions::modals /> to you livewire view?
Ben
BenOP15mo ago
Sorry for late response. Yes, I did
<div>
{{ $this->addLinkAction }}

<x-filament-actions::modals />
</div>
<div>
{{ $this->addLinkAction }}

<x-filament-actions::modals />
</div>
awcodes
awcodes15mo ago
Maybe try Action::make(‘addLink’) don’t use the prebuilt CreateAction.
Lodret
Lodret13mo ago
@Ben do you get the solution for it, i got the same issue
Ben
BenOP13mo ago
I gave up, I don't have more time to dig on this issue. So, I moved on. I choose to have the trigger button on the panels::content.start, it just works as long as the trigger button inside the <main> tag
No description
Lodret
Lodret13mo ago
are you using the button blade components?
Ben
BenOP13mo ago
Yes, also this Action::make(‘addLink’) and CreateAction::make(‘addLink’) I didn't try it on the latest version yet, maybe later I'll give one more try
Lodret
Lodret13mo ago
okay thanks ben for answer, i got bit insight there's actualy still bug, im using lastest filament version and put the Action modal in render hooks after
panels::page.header.actions.after
panels::page.header.actions.after
Want results from more Discord servers?
Add your server