open action when a GET parameter is set
I'd like to open a specific action when a user comes to a page and a specific $_GET parameter is present.
It's an edit form of a resource, which contains a header action button. Which has a wireclick:
I would like to automatically open this action when my URL looks like this:
/admin/education/1/edit?openPlanningForm=true
Is there a way to do this? I was thinking of dispatching something in the mount method , but I don't know what i should dispatch.
My edit page:
Any tips?
10 Replies
I tried this, but does nothing:
i could register a script and trigger it on the frontend maybe, but isn't there an easier way?
$this->dispatch('open-modal', id: 'edit-user');
Thank you!
Im assuming the modal name is the same as the action?

doing this in mount or the livewire rendered hook doesnt trigger the modal:
After inspecting the mountAction method i can see a modal is called like this:
, id: "{$this->getId()}-action");
mm yeah, when you click the button by hand
this is the modal that is being opened

So in mount after the parent, if you then call it to open it should work I believe? Else use the js method
ye but i dont know that ID
in my code
ill trigger a button click, that has the same effect/result
thanks for the help!
Ahh ok, no problem!
I solved it, it feels a bit nasty, but hey it works.
I added a custom data attribute to the action button.
Gave the edit resource its own blade view (just copied the original one)
Added this on top of the blade file:
mm i think i can better just hard @include the original in my own blade view
yeah nice this works fine
Not going to mark this as answer because i have a feeling this is not the most optimal way 😛