Programmatically open relationManager View/Edit modal
Goal
I have linked two relationManagers to a Resource (parent).
On the parent I would like to be able to call a function which opens the
View/Edit
action on a specific record in the relationManager.
Motivation
It would be great to "deeplink" to a record in a resource. What I mean by this is that I would like to be able to craft links like "/app/example/12#books-34". This link would open the example resource (id 12)
and trigger the View/Edit
on the book (id 34)
record in the BooksRelationManager.
Question
Is this possible? How could I do this?11 Replies
To communicate between the resource and the relationmanager, I will probably use livewire events/listeners
Nested relationship url aren’t totally possible in filament v3. There is a plugin for them and it’s coming to v4, but also using a hashtag isn’t really the way nested resources work in laravels routing out of the box.
Yes, I understand that the routing part is seperate. But how do I programmatically open a edit/view modal in a contactrelation manager?
When clicking on a resource in a relation manager I see (using wirespy) that the following event is fired:
If I fire that event manually, somehow an close event is also fired immediately
I looked some more and saw that,
mountTableAction
is used.If I fire that myself using
$this->mountTableAction('view', '01jae6rvajt6y1w4twyms7b3wv');
The autoclose happens again but now a blur on the screen does appear.This is the action I use to test:
Why when triggering the mountTableAction manually does the
params
get set to the action name instead of the value I pass?I've also tried the following:
https://filamentphp.com/docs/3.x/actions/adding-an-action-to-a-livewire-component#programmatically-triggering-actions
This just results in nothing happening
Okay I've made some progress. This works:
Now I want to figure out how to trigger this behaviour from another place in livewire
Solution
I figured it out! 🥳
Gist
Filament V3 - Deeplink RelationManager
Filament V3 - Deeplink RelationManager. GitHub Gist: instantly share code, notes, and snippets.