Secondary Modal Submit Action with RequiresConfirmation

Im trying to add another submit action on a modal that requires a confirmation. Tried adding that, but cant seem to get access to the original actions form. Any suggestions? I tried also using makeSubmitAction too, but it doesnt allow you to add a requiresConfirmation or much else to it.
->modalFooterActions(function (Action $action) {
return [
$this->terminationRequiresReview() ? $this->submitTerminationForReviewAction($action) : $action->getModalSubmitAction(),
$action->getModalCancelAction(),
];
})

$this->submitTerminationForReviewAction(Action $parentAction): Action
{
return Action
->label('Submit for Review')
->requiresConfirmation()
->modalWidth(MaxWidth::ExtraLarge)
->modalHeading('Submit for Review')
->modalDescription('Are you sure you are ready to submit this action?')
->infolist([
ShoutEntry::make('review-alert')
->content('Once reviewed you will be notified of the results of the review and provided with instructions for next steps.'),
])
->action(function (Action $action) {
// need access to form data and it should be validated first like the normal submit action
$this->saveFormData();
$action->cancelParentActions();
});
}
->modalFooterActions(function (Action $action) {
return [
$this->terminationRequiresReview() ? $this->submitTerminationForReviewAction($action) : $action->getModalSubmitAction(),
$action->getModalCancelAction(),
];
})

$this->submitTerminationForReviewAction(Action $parentAction): Action
{
return Action
->label('Submit for Review')
->requiresConfirmation()
->modalWidth(MaxWidth::ExtraLarge)
->modalHeading('Submit for Review')
->modalDescription('Are you sure you are ready to submit this action?')
->infolist([
ShoutEntry::make('review-alert')
->content('Once reviewed you will be notified of the results of the review and provided with instructions for next steps.'),
])
->action(function (Action $action) {
// need access to form data and it should be validated first like the normal submit action
$this->saveFormData();
$action->cancelParentActions();
});
}
Solution:
try ```php ->modalFooterActions([ Action::make('save_confirm') ->label('aubmit for review')...
Jump to solution
15 Replies
toeknee
toeknee4d ago
->modalSubmitAction(fn($action) => $action->requiresConfirmation()) ?
Mark Chaney
Mark ChaneyOP4d ago
@toeknee Doesn't appear to support requiresConfirmation()
toeknee
toeknee4d ago
Ahh of course you can just use a normal action then and apply your own action method to save first
Mark Chaney
Mark ChaneyOP4d ago
@toeknee sorry, not completely following you
toeknee
toeknee4d ago
try:
->modalFooterActions([
Action::make('save_confirm')
->label('aubmit for review')
->submit('save')
->requiresConfirmation()
->keyBindings(['mod+s'])
])
->modalFooterActions([
Action::make('save_confirm')
->label('aubmit for review')
->submit('save')
->requiresConfirmation()
->keyBindings(['mod+s'])
])
Mark Chaney
Mark ChaneyOP4d ago
@toeknee ah, didnt know about submit. Though seems to just save it and ignores the requiresconfirmation
Solution
toeknee
toeknee4d ago
try
->modalFooterActions([
Action::make('save_confirm')
->label('aubmit for review')
->requiresConfirmation()
->action('save')
->keyBindings(['mod+s'])
])
->modalFooterActions([
Action::make('save_confirm')
->label('aubmit for review')
->requiresConfirmation()
->action('save')
->keyBindings(['mod+s'])
])
Mark Chaney
Mark ChaneyOP4d ago
@toeknee I think that did it. Thanks so much for your personal help. Really appreciate it!
toeknee
toeknee4d ago
Most Welcome!
Mark Chaney
Mark ChaneyOP4d ago
@toeknee sorry, i lied. While I am definitely still thankful, it seems that $data never gets to that footer action. I know I am probably missing something simple and do appreciate your patience if its just going over for head for some reason.
toeknee
toeknee4d ago
Actually that makes sense.... I would just do:
->modalFooterActions([
Action::make('save_confirm')
->label('aubmit for review')
->requiresConfirmation()
->action(function($record, $data) {
$record->update($data);
})
->keyBindings(['mod+s'])
])
->modalFooterActions([
Action::make('save_confirm')
->label('aubmit for review')
->requiresConfirmation()
->action(function($record, $data) {
$record->update($data);
})
->keyBindings(['mod+s'])
])
is similar?
Mark Chaney
Mark ChaneyOP4d ago
yes, thats my original problem that i posteda bout. $data is always an empty array
toeknee
toeknee4d ago
Of course because $data is expected from a form on the action, one minute. let me work out the save logic
dissto
dissto4d ago
$livewire->data potentially?
Mark Chaney
Mark ChaneyOP4d ago
@dissto i can check again, but im pretty sure that looks at the form of the page and not that of the parent action @dissto yep, actually i think $livewire->mountedActionsData[0] actually will give me the data

Did you find this page helpful?