#replaceMountedAction() only works if chained action is 'publish'

7 messages · Page 1 of 1 (latest)

stark lintel
#

Not sure if I am doing something wrong. This works as expected:


public function editAction(): Action
    {
        return Action::make('edit')
            ->label('Edit')
            ->schema([
                TextInput::make('title')->required(),
                Select::make('status')->options([
                    'draft' => 'Draft',
                    'published' => 'Published',
                ]),
            ])
            ->action(function (array $data, Model $record) {

                // Chain the publish action after edit
                $this->replaceMountedAction('publish', [
                    'info' => 'Indiana Jones',
                    'record' => $record
                ]);
            });
    }


public function publishAction(): Action
    {
        return Action::make('publish')
            ->label('Publish')
            ->requiresConfirmation()
            ->action(function (array $arguments) {
                dd($arguments);
            });
    }

Change action name in publish to anything else and it stops working. I am wondering what I am missing.

vale sinewBOT
#

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

stark lintel
# stark lintel Not sure if I am doing something wrong. This works as expected: ```php publi...

This does not work.


public function publishAction(): Action
    {
        return Action::make('publisher')
            ->label('Publish')
            ->requiresConfirmation()
            ->action(function (array $arguments) {
                dd($arguments);
            });
    }

public function editAction(): Action
    {
        return Action::make('edit')
            ->label('Edit')
            ->schema([
                TextInput::make('title')->required(),
                Select::make('status')->options([
                    'draft' => 'Draft',
                    'published' => 'Published',
                ]),
            ])
            ->action(function (array $data, Model $record) {

                // Chain the publish action after edit
                $this->replaceMountedAction('publisher', [
                    'info' => 'Indiana Jones',
                    'record' => $record
                ]);
            });
    }

The only difference is publish becomes publisher

gusty iron
#

I'm pretty sure the method name has to match the action name, so it would need to be publisherAction()

stark lintel
#

Oh!
Let me check that out.

gusty iron
stark lintel
#

You are right and I missed it.
Thank you