Widget Table Action with modal form - dispatch refresh event not working
Hi all,
I have a Table Widget with two Actions, while the participate action is refreshing the Widget, the participateProxy action does not.
So "participate" works, "participateProxy" not.
Any Idea?
Action::make('participate')
->iconButton()
->icon(hero('user-plus'))
->color('success')
->label(__('realty.meeting.in-person'))
->tooltip(__('realty.meeting.in-person'))
->action(function (RealtyMeetingCurrentOwner $record) use ($meeting) {
$meeting->addParticipant(Owner::find($record->owner_id), Contact::find($record->contact_id));
$this->dispatch('refreshComponent');
self::notifySuccess();
}),
Action::make('participateProxy')
->disabled(fn () => $meeting->participantsInPerson->isEmpty())
->iconButton()
->label(__('realty.meeting.is-proxy'))
->tooltip(__('realty.meeting.is-proxy'))
->color('secondary')
->icon(hero('document-plus'))
->modalWidth('md')
->modalHeading(__('realty.meeting.is-proxy'))
->form($this->participationFormSchema())
->action(function (?RealtyMeetingCurrentOwner $record, ?array $data) {
$this->addParticipant($record, $data);
self::notifySuccess();
})
->after(fn () => $this->dispatch('refreshComponent') ),
Thanks6 Replies
you mean, participate works, participateProxy doesn't work?
@LeandroFerreira Thanks for your reply. Yes, exactly.
participateProxy
has a form. I think refreshComponent
should be dispathed after the form is submitted. If ->after(fn() => dd('refreshComponent'))
doesn't work, I think there is something in the action(...)
that is halting the proccess and preventing after
method from executing.dd() is working in the ->after(). That’s why I don’t know what could be the problem, and how to debug.
check
$this->addParticipant($record, $data)
and self::notifySuccess()
I did all the checks, changed the action code to a simple one, still not working.
I created a bulk action "participateProxyBulk" with exact the same action logic, and there the refresh is working...but not for the single header action.
->bulkActions([
BulkAction::make('participateProxyBulk')
->disabled(fn () => $meeting->participantsInPerson->isEmpty())
->label(__('realty.meeting.is-proxy'))
->color('secondary')
->icon(hero('document-plus'))
->modalWidth('md')
->modalHeading(__('realty.meeting.is-proxy'))
->form($this->participationFormSchema())
->action(function (Collection $records, array $data) {
foreach ($records as $record) {
$this->addParticipant($record, $data);
}
self::refresh();
self::notifySuccess();
}),
])
->actions([
Action::make('participateProxy')
->disabled(fn () => $meeting->participantsInPerson->isEmpty())
->iconButton()
->label(__('realty.meeting.is-proxy'))
->tooltip(__('realty.meeting.is-proxy'))
->color('secondary')
->icon(hero('document-plus'))
->modalWidth('md')
->modalHeading(__('realty.meeting.is-proxy'))
->form($this->participationFormSchema())
->action(function (RealtyMeetingCurrentOwner $record, array $data) {
$this->addParticipant($record, $data);
self::refresh();
self::notifySuccess();
}),
]);