F
Filament6mo 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
MaxOP6mo ago
No description
Max
MaxOP6mo ago
Tried this without any luck Same question in <#1098265690588319754> never answered
awcodes
awcodes6mo 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
LeandroFerreira6mo 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
MaxOP6mo ago
No description
Max
MaxOP6mo ago
Max
MaxOP6mo ago
Still not working :/ This works for the create form but I cannot find an equivilant for the edit form acction
LeandroFerreira
LeandroFerreira6mo ago
you should use getSaveFormAction instead of getCreateFormAction
Solution
LeandroFerreira
LeandroFerreira6mo 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