Close open modal from listener on PHP side?
I am halting my form submission on a subscription relation manager's table header action:
->headerActions([
CreateAction::make()
->label('New subscription')
->modalWidth('md')
->action(function ($data, $livewire, $action) {
$livewire->dispatch('stripe-payment', data: $data);
// Prevent the modal from closing
$action->halt();
})
])
This is so I can have the content of my stripe payment field processed separately.
Once my stripe payment field's validation has run and is successful, I trigger this event:
Livewire.dispatch('finalize-subscription-create')
In the listener on the PHP side, I want to close the open modal and send out a notification. I am trying:
#[On('finalize-subscription-create')]
public function finalizeSubscriptionCreate()
{
$this->dispatch('close-action-modal');
Notification::make()
->title('Subscription created')
->success()
->send();
}
The notification is sent but the modal is not closed. Can anyone advise on how to do this please?Solution:Jump to solution
Use something like that
```php
->action(function ($data, $livewire, $action) {
...
2 Replies
Solution
Use something like that
Thank you, I got it working 👍