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(),


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');
  }),
Solution
You can try something like $livewire->mountFormComponentAction() or sth
Was this page helpful?