F
Filament5mo ago
Max

add requiresConfirmation to save action on Edit - Resource

Hey there, im trying to add a conditional conformation message when the user clicks the save button on the edit form. Any help?
Solution:
```php protected function getSaveFormAction(): Action { return parent::getSaveFormAction() ->submit(null)...
Jump to solution
9 Replies
Max
MaxOP5mo ago
No description
Max
MaxOP5mo ago
Tried this without any luck Same question in <#1098265690588319754> never answered
awcodes
awcodes5mo ago
The save action is already defined separately so you’re not actually overriding it by calling it ‘save’. You should be able to do something like this instead of creating a new save action.
$this->getSaveAction()->requiresConfirmation()
$this->getSaveAction()->requiresConfirmation()
LeandroFerreira
LeandroFerreira5mo ago
Leandro Ferreira (@leandrocfe) on X
💡 Filament Tip: If you want to enhance the Create Form by adding a confirmation modal before submission, use the following code snippet 👇
From An unknown user
Twitter
Max
MaxOP5mo ago
No description
Max
MaxOP5mo ago
Max
MaxOP5mo ago
Still not working :/ This works for the create form but I cannot find an equivilant for the edit form acction
LeandroFerreira
LeandroFerreira5mo ago
you should use getSaveFormAction instead of getCreateFormAction
Solution
LeandroFerreira
LeandroFerreira5mo ago
protected function getSaveFormAction(): Action
{
return parent::getSaveFormAction()
->submit(null)
->requiresConfirmation()
->action(function () {
$this->closeActionModal();
$this->save();
});
}
protected function getSaveFormAction(): Action
{
return parent::getSaveFormAction()
->submit(null)
->requiresConfirmation()
->action(function () {
$this->closeActionModal();
$this->save();
});
}
Want results from more Discord servers?
Add your server