#How to reorder button on edit resource
27 messages · Page 1 of 1 (latest)
I would like to look like on the picture bellow
Very quick and simple way would be to edit the EditPage.php
and add:
protected function getFormActions(): array
{
return array_reverse(parent::getFormActions());
}
Thank you for marking this question as solved!
Do you maybe know how i can rename the save text button i try with ``` protected function getFormActions(): array
{
$inputs = array_reverse(parent::getFormActions());
$inputs[1]->label = 'Save changes and keep editing'; // i get the error here: label is protected
return $inputs;
}
in "getFormActions()" you can pass manually an array of actions. just put manually the CancelAction::make() and SaveAction::make()->label('new text')
what is the namespace for the CancelAction and SaveAction
do it like this:
use Filament\Pages\Actions\Action;
...
Action::make('close')
->label('Close')
->cancel(),
Action::make('submit')
->label('Save ...')
->submit(),
I get the error for the cancel()
which error
are you in the EditPage?
app/Filament/Resources/MineResource/Pages/EditResource.php
this is mine path where i paste your code
my fault, ->cancel() is only for modalActions, I think..
do this, it works:
$this->getCancelFormAction(), Action::make('submit')
->label('Save ...')
->submit(),
or:
$this->getCancelFormAction(), $this->getSaveFormAction()->label('new label')
Just replace the actions with a clone of the save and cancel actions...
protected function getFormActions(): array
{
return[
Action::make('cancel')
->label(__('filament-panels::resources/pages/edit-record.form.actions.cancel.label'))
->alpineClickHandler('document.referrer ? window.history.back() : (window.location.href = ' . Js::from($this->previousUrl ?? static::getResource()::getUrl()) . ')')
->color('gray'),
Action::make('save')
->label('save')
->submit('save')
->keyBindings(['mod+s'])
];
}
This solution works for me. Thank you all
And you @lucid plank thanks
Does anyone knows how i can reorder the buttons on the modal
What is it you want to do? exactly? You can clone the default action buttons and add them in
To swap these button the button create must be last, cancel button first mine code is ``` Select::make('tag_id')
->required()
->preload(true)
->relationship('tags', 'title')
->label('Tags')
->searchable()
->multiple()
->createOptionForm([
TextInput::make('title')
->unique()
->required()
->maxLength(255)
])->createOptionAction(function(Action $action){
$action->mutateFormDataUsing(function(array $data){
$data['slug'] = $data['title'];
return $data;
});
}),```
