F
Filamentβ€’4mo ago
d3v1anX

how to open edit modal from link?

hey guys, I implemented a filament table into a livewire component. On it there is a edit modal for each entry. Now I want to create a link on another page to this table, which opens the edit modal for an entry directly. I tried so many things like "&id=XXX" and checking in mount of livewire if request()->has('id') -> then try to "mountTableAction('edit', XXX)" but this will not work because Table is not initalized on mount. Then I tried to call with a direct link to "action=edit" like you can do with "action=create", but this won't work with integrating in livewire. Now I'm struggeling with some kind of Javascript to $wire.call('mountTableAction'...) but this also does not work and I think it surely can be easier.. πŸ˜„ Has anyone an idea how I can call the edit modal for a record after loading the table?
Solution:
I solved it by myself: ```php <div @if(request()->has('id')) x-data="{}" x-init="$wire.$dispatch('openModal', [{{ request()->id }}])"...
Jump to solution
1 Reply
Solution
d3v1anX
d3v1anXβ€’4mo ago
I solved it by myself:
<div @if(request()->has('id')) x-data="{}"
x-init="$wire.$dispatch('openModal', [{{ request()->id }}])"
@endif
>
<div @if(request()->has('id')) x-data="{}"
x-init="$wire.$dispatch('openModal', [{{ request()->id }}])"
@endif
>
and
#[On('openModal')]
public function openModal($entry)
{
$this->mountTableAction('edit', $entry);
}
#[On('openModal')]
public function openModal($entry)
{
$this->mountTableAction('edit', $entry);
}
Maybe there is a better solution, but it works πŸ˜„
Want results from more Discord servers?
Add your server