extraModalFooterActions, retrieving post $data?

I have a system to make schedules, schedules can be recurring. I want to have an extra FooterAction to "Save all future recurring schedules" instead of just the current one. Got that all to work with this (https://filamentphp.com/docs/3.x/actions/modals#adding-an-extra-modal-action-button-to-the-footer) But the problem is I cant add a requireConfirmation() to it then. That works with this perfectly BUT i can't retrieve the form $data (because it is a child?) Is there any method to fix this? My code:
return Actions\EditAction::make()
->modalHeading(__('Edit shift'))
->form(ScheduleResource::getFormSchema())
->modalSubmitActionLabel(__('Edit only this shift'))
->extraModalFooterActions([
Action::make('editAll')
->label(__('Edit all future shifts'))
->requiresConfirmation()
->action(function (Schedule $record, array $data) {
dd($data);
// returns null :(
})
,
Action::make('delete')
->hiddenLabel()
->icon('heroicon-s-trash')
->color('danger')
->requiresConfirmation()
->tooltip(__('Delete this shift'))
->cancelParentActions()
->action(function (Schedule $record) {
$record->delete();
$this->refreshRecords();
}),
return Actions\EditAction::make()
->modalHeading(__('Edit shift'))
->form(ScheduleResource::getFormSchema())
->modalSubmitActionLabel(__('Edit only this shift'))
->extraModalFooterActions([
Action::make('editAll')
->label(__('Edit all future shifts'))
->requiresConfirmation()
->action(function (Schedule $record, array $data) {
dd($data);
// returns null :(
})
,
Action::make('delete')
->hiddenLabel()
->icon('heroicon-s-trash')
->color('danger')
->requiresConfirmation()
->tooltip(__('Delete this shift'))
->cancelParentActions()
->action(function (Schedule $record) {
$record->delete();
$this->refreshRecords();
}),
I feel like maybe this could help (https://discord.com/channels/883083792112300104/1237435510100594719/1237599157187903558) but maybe I am missing something obivous?
2 Replies
Dennis Koch
Dennis Koch2mo ago
Those methods don't have a form so where should the data come from? You can try fn ($action) => $action->data or ->formData or similar
Sjoerd24
Sjoerd242mo ago
Yeah I now better understand the problem, that makes sense. If I dd($action) i dont see any form data in there. How can I solve this problem though? Or I have to just revert to something like:
->extraModalFooterActions(fn (Action $action): array => [
// but without the requiresConfirmation() method
$action->makeModalSubmitAction('editAllFutureOccurrences', arguments: ['action' => 'editAll' ])
->color('warning')
->label(__('Edit all future shifts')),
->extraModalFooterActions(fn (Action $action): array => [
// but without the requiresConfirmation() method
$action->makeModalSubmitAction('editAllFutureOccurrences', arguments: ['action' => 'editAll' ])
->color('warning')
->label(__('Edit all future shifts')),
I tried adding something like a mix between the two:
->extraModalFooterActions([
Action::make('editAll')
->label(__('Edit all future shifts'))
->color('warning')
//->requiresConfirmation()
//->cancelParentActions()
->makeModalSubmitAction(name: 'editAllFutureOccurrences', arguments: ['action' => 'editAll' ])
->extraModalFooterActions([
Action::make('editAll')
->label(__('Edit all future shifts'))
->color('warning')
//->requiresConfirmation()
//->cancelParentActions()
->makeModalSubmitAction(name: 'editAllFutureOccurrences', arguments: ['action' => 'editAll' ])
But using ->makeModalSubmitActionmakes the Action static..? I would also think that adding a second button to update all events (with requiresConfirmation) wouldn't be this hard. 😅 Ok so this works, but it feels very dirty:
->action(function (Schedule $record, Component $livewire) {
dd($livewire->mountedActionsData[0]);
// this outputs the correct form data
})
->action(function (Schedule $record, Component $livewire) {
dd($livewire->mountedActionsData[0]);
// this outputs the correct form data
})
Hope this helps someone else, but I hope there is a better way of doing this. ugh relationships are not save like this of course, anyone a better solution?