Open a Modal when field state changes

Is it possible to open a modal when the field state changes. I need to add something like this to the Toggle field using a Macro.
Toggle::make('is_published')
->requiresConfirmation(),
Toggle::make('is_published')
->requiresConfirmation(),
Has anyone tried something, any trick? We could dispatch the open-modal event but then we also need to register it somewhere and should be able to cancel/proceed the toggle state.
Toggle::make('is_published')
->live()
->afterStateUpdated(function (Component $livewire) {
$livewire->dispatch('open-modal', 'modal-id');
}),
Toggle::make('is_published')
->live()
->afterStateUpdated(function (Component $livewire) {
$livewire->dispatch('open-modal', 'modal-id');
}),
Solution:
You can try something like $livewire->mountFormComponentAction() or sth
Jump to solution
3 Replies
Solution
ralphjsmit
ralphjsmit8mo ago
You can try something like $livewire->mountFormComponentAction() or sth
Mansoor Khan
Mansoor KhanOP8mo ago
Thanks, let me try that. Wow, you are a genius. This worked like a charm. Thanks..
ralphjsmit
ralphjsmit8mo ago
Awesome!
Want results from more Discord servers?
Add your server