#How to reorder button on edit resource

27 messages · Page 1 of 1 (latest)

manic spindle
#

Is it possible to reorder buttons on edit reource that mine primary button is right and cancel button is left

dusty torrentBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

manic spindle
#

I would like to look like on the picture bellow

lucid plank
#

Very quick and simple way would be to edit the EditPage.php

and add:

    protected function getFormActions(): array
    {
        return array_reverse(parent::getFormActions());
    }
dusty torrentBOT
manic spindle
gritty delta
#

in "getFormActions()" you can pass manually an array of actions. just put manually the CancelAction::make() and SaveAction::make()->label('new text')

manic spindle
#

what is the namespace for the CancelAction and SaveAction

gritty delta
#

do it like this:

use Filament\Pages\Actions\Action;
...
Action::make('close')
->label('Close')
->cancel(),
Action::make('submit')
->label('Save ...')
->submit(),
manic spindle
#

I get the error for the cancel()

gritty delta
#

which error

manic spindle
#

just these and then mark cancel function

gritty delta
#

are you in the EditPage?

manic spindle
#

app/Filament/Resources/MineResource/Pages/EditResource.php

#

this is mine path where i paste your code

gritty delta
#

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')
lucid plank
#

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'])
        ];
    }
manic spindle
#

And you @lucid plank thanks

manic spindle
#

Does anyone knows how i can reorder the buttons on the modal

lucid plank
manic spindle
#

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;
                });
            }),```