Chaining Actions
I have Reset Password Action. That action is going to require confirmation and then change the password. I have that working. How do i then after that display a slideover() form with that temporary password? Basically, how do i launch another modal/form within
->after()
?15 Replies
I have everything pretty much built out except initiating that second form.
Very interested to see if there is a solution for this, as I have several actions that could do with this kind of treatment - providing feedback after the initial modal form is displayed and submitted. Atm I'm having to make do with notifications.
@cheesegrits I needed to move on myself an simply doing an notification too. Obviously I could do my own modal and use emit to launch it, but i dont feel i should have to recreate all that from scratch
I suspect it may be something that happens in v3 at some point. The new Actions package is getting a lot of love.
i dont know how id implement nested modals
I'm not sure about MAC's usage, but for me it's more chained than nested. Although I guess that depends on how one defines "nested". The usage I find myself wanting is triggering subsequent actions that receive the results of the previous one.
https://github.com/wire-elements/modal does a great job with being able to do that
GitHub
GitHub - wire-elements/modal: Livewire component that provides you ...
Livewire component that provides you with a modal that supports multiple child modals while maintaining state. - GitHub - wire-elements/modal: Livewire component that provides you with a modal that...
but yes, we are mainly talking about actions after each other
I'd like to be able to return a data array from one action, and pass it in to the mountUsing of another, and/or some kind of "trigger" function which determines whether the next action runs ... top of my head ...
I don’t know how that would be accomplished but I like the idea of it. Something like Laravel’s new Process but for actions.
Perfect world, the array of actions would could be any length, it just checks the trigger (if present) for each in turn with the current response $data (or just runs it if no trigger).
Seems like a wizard would be easier though. 😜
Especially for a11y.
Might actually be possible though by maintaining the form data at the parent level and injecting it through evaluation.
I was going to say, this is kind of "Action Wizards".
Most of my cases are relatively simple though, of just wanting to either handle an error from the main action (where the user needs to choose between options for remedial action), or (like MAC's example) give them some result from the main action that doesn't fit into a notification paradigm.
No doubt. I think that’s where halt() fits in but it’s not as straightforward as that. But I definitely see the point and the use case.
Oh, right, yeah, would need a halt() I guess. Or have the trigger() return true (run action), null (no opinion, ask the next action) or false (halt).
The more I think about it, the more use cases I see in my apps for it, and the more logic I could offload to actions.