Why modalFooterActions can not register an third action

I would like to have three buttons on mine slide over how i can make it? i look but it does not render mine three buttons just two what i should do so i can make it i have three buttons
->actions([
Tables\Actions\EditAction::make()
->slideOver()
->modalHeading(function(Team $teamMember){
return "Edit " . $teamMember->name['en'];
})
->modalFooterActions(function($action){
return [
Actions\Action::make('cancel')
->extraAttributes(['class' => 'secondary-btn'])
->action(function () {
$this->validate();
$this->save();
}),
Actions\Action::make('save and keep editing')
->extraAttributes(['class' => 'secondary-btn'])
->action(function () {
$this->validate();
$this->save();
}),
Actions\Action::make('save changes')
->extraAttributes(['class' => 'secondary-btn'])
->action(function () {
$this->validate();
$this->save();
}),
];
}),
->actions([
Tables\Actions\EditAction::make()
->slideOver()
->modalHeading(function(Team $teamMember){
return "Edit " . $teamMember->name['en'];
})
->modalFooterActions(function($action){
return [
Actions\Action::make('cancel')
->extraAttributes(['class' => 'secondary-btn'])
->action(function () {
$this->validate();
$this->save();
}),
Actions\Action::make('save and keep editing')
->extraAttributes(['class' => 'secondary-btn'])
->action(function () {
$this->validate();
$this->save();
}),
Actions\Action::make('save changes')
->extraAttributes(['class' => 'secondary-btn'])
->action(function () {
$this->validate();
$this->save();
}),
];
}),
8 Replies
mile4841
mile48417d ago
No description
LeandroFerreira
they should be Tables\Actions\Action actions
mile4841
mile48417d ago
i did it but is there an option that this action createAnother does not close the modal
->modalFooterActions(function(Tables\Actions\Action $action){
return [
$action
->getModalCancelAction()
->extraAttributes(['class' => 'third-btn']),
$action->makeModalSubmitAction('createAnother', arguments: ['another' => true])
->label('Save and create another')
->extraAttributes(['class' => 'secondary-btn']),
$action
->getModalSubmitAction()
->label('Save'),
];
}),
->modalFooterActions(function(Tables\Actions\Action $action){
return [
$action
->getModalCancelAction()
->extraAttributes(['class' => 'third-btn']),
$action->makeModalSubmitAction('createAnother', arguments: ['another' => true])
->label('Save and create another')
->extraAttributes(['class' => 'secondary-btn']),
$action
->getModalSubmitAction()
->label('Save'),
];
}),
LeandroFerreira
I think you should create a new action if you need a custom action
return [
$action
->getModalCancelAction(),
Tables\Actions\Action::make('createAnother')
->action(function () {
//...
}),
$action
->getModalSubmitAction()
->label('Save'),
];
return [
$action
->getModalCancelAction(),
Tables\Actions\Action::make('createAnother')
->action(function () {
//...
}),
$action
->getModalSubmitAction()
->label('Save'),
];
mile4841
mile48417d ago
do you maybe how i can validate inside an action function
->modalFooterActions(function(Tables\Actions\Action $action){
return [
$action
->getModalCancelAction()
->extraAttributes(['class' => 'third-btn']),
Tables\Actions\Action::make('save and keep editing')
->action(function($record) {
// how to validate here
// does not work $this->validate();
// also does not work $record->validate();
$record->save();
})
->extraAttributes(['class' => 'secondary-btn']),
$action
->getModalSubmitAction()
->label('Save'),
];
}),
->modalFooterActions(function(Tables\Actions\Action $action){
return [
$action
->getModalCancelAction()
->extraAttributes(['class' => 'third-btn']),
Tables\Actions\Action::make('save and keep editing')
->action(function($record) {
// how to validate here
// does not work $this->validate();
// also does not work $record->validate();
$record->save();
})
->extraAttributes(['class' => 'secondary-btn']),
$action
->getModalSubmitAction()
->label('Save'),
];
}),
do you have any ideas how to solve these
LeandroFerreira
would you like to add an action to "save and keep editing" ? are you using a simple resource with modals, right?
mile4841
mile48417d ago
yes i just want to validate and save i am using slideOver
LeandroFerreira
hum.. I think you could achieve this using makeModalSubmitAction (https://filamentphp.com/docs/3.x/actions/modals#adding-an-extra-modal-action-button-to-the-footer). However, you would need to override the action method of EditAction, and I’m not sure if that’s a good idea because there are some processes involved.
Want results from more Discord servers?
Add your server