#Table Header Action Confirmation not work

8 messages · Page 1 of 1 (latest)

odd forum
#

basically I want to set the confirmation for this header table action but the confirmation not worked.
any help please ?

            ->headerActions([
                Action::make('create')
                    ->requiresConfirmation()
                    ->label('Create User')
                    ->icon('heroicon-o-plus-circle')
                    ->color('success')
                    ->form([
                        TextInput::make('name')
                            ->label('Full Name')
                            ->placeholder('John Doe')
                            ->required()
                            ->maxLength(255)
                            ->prefixIcon('heroicon-o-user')
                            ->columnSpanFull(),
                       
                    ])
                    ->action(function (array $data) {
                        User::create([
                            'name' => $data['name'],
                           
                        ]);
                    })
                    ->cancelParentActions()
                    ->modalHeading('Create User')
                    ->modalDescription('Create a new user')
                    ->modalSubmitActionLabel('Create User')
                    ->modalCancelActionLabel('Cancel')
                    ->modalWidth('md'),
pure fieldBOT
#

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

half pawn
#

Is there another create action on the page?

odd forum
#

No actually, I wanna use inside a relation manager table

#

I mean this action

half pawn
#

Hmm. Code looks ok. Try moving the require after the form and removing the cancelParentActions

odd forum
#

you mean that

->headerActions([
                Action::make('create')
                    ->form([
                        TextInput::make('name')
                            ->label('Full Name')
                            ->placeholder('John Doe')
                            ->required()
                            ->maxLength(255)
                            ->prefixIcon('heroicon-o-user')
                            ->columnSpanFull(),
                       
                    ])
                    ->action(function (array $data) {
                        User::create([
                            'name' => $data['name'],
                           
                        ]);
                    })
                    ->requiresConfirmation(),

I tried that, not worked !

half pawn
#

I would put it above the action. Sometimes the order of the methods matter. What exactly isn’t working?

Maybe try renaming the action to something like ‘customCreate’ just as a test.