#replaceMountedAction isn't working for me

6 messages · Page 1 of 1 (latest)

drowsy mesa
#

I've googled, searched this discord channel and tried hundreds of possibilities, but it just isn;t working for me. It seems simple what I want to do, button calls an action so I can do some lookups etc, then if lookups work I want to chain another action that will display something and call it's own action.

I am on a resource and in the Form code.

class ReturnOrderForm
{

    public static function firstAction(): Action
    {
        return Action::make('first')
            ->action(function ($livewire) {
                //  dd($livewire);

                $livewire->replaceMountedAction('second');
            });
    }

    public static function secondAction(): Action
    {
        return Action::make('second')
            ->requiresConfirmation()
            ->modalHeading('Step 2')
            ->action(function ($livewire) {

                dd('2');
            });
    }

Somewhere in my form, I add the folllowing to render the action button.

self::firstAction(),

I did have it as a suffixaction on a textinput but that didnt work either.

          TextInput::make('serial')->autofocus()->label('Serial Number')->suffixAction(
                self::firstAction()->label('Add')->button()
          ),

First button action works, I can dd to see this, but second one doesn't fire and I see no errors in Console.

empty stagBOT
#

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

supple crow
#

Shouldn't that just be $this->replaceMountedAction(), not $livewire?

drowsy mesa
lilac sphinx
#

I think the issue is, that you never registered the 2nd method anywhere. Try to add it to the schema and make it hidden

drowsy mesa