How to registerAction on table selectColumn ?

SelectColumn::make('subject')
->options([])
->registerActions()
SelectColumn::make('subject')
->options([])
->registerActions()
This did not work
7 Replies
Asmit Nepali
Asmit Nepali2mo ago
Here I would like to trigger confirmation dialog box here Does anyone have any ideas about this please
Tonkawuck
Tonkawuck2mo ago
I looked into this briefly and you'll be fighting with the SelectColumn to do this. I recommend adding a table row Action with a ->form() and ->requiresConfirmation() to do this.
Asmit Nepali
Asmit Nepali2mo ago
Could you please provide example of that, what you are trying to say, It would be very helpful.
Tonkawuck
Tonkawuck2mo ago
You can add an action on the table row like this:
Tables\Actions\Action::make('change_subject')
->fillForm(function(array($data) {}), // Populate this closure to set inital state
->form(fn(Form $form) =>
$form->schema([
Forms\Components\Select::make('subject')
->options([
//
])
])
)
->requiresConfirmation()
->action(function(Model $record, array $data) {
$record->update(['subject' => $data['subject']]);
}),
Tables\Actions\Action::make('change_subject')
->fillForm(function(array($data) {}), // Populate this closure to set inital state
->form(fn(Form $form) =>
$form->schema([
Forms\Components\Select::make('subject')
->options([
//
])
])
)
->requiresConfirmation()
->action(function(Model $record, array $data) {
$record->update(['subject' => $data['subject']]);
}),
e
Asmit Nepali
Asmit Nepali2mo ago
Thank you @Tonkawuck , But I have to update subject from table Hello
Asmit Nepali
Asmit Nepali2mo ago
Thank you @Leandro Ferreira @Leandro Ferreira https://discord.com/channels/883083792112300104/1247909942317547601/1250347583277105242 This work for now but I tried in a different way This is my table column
SelectColumn::make('subject')
->options(SubjectClass::class)
->updateStateUsing(function (Page $livewire, $record) {
return $livewire->mountAction('updateSubject');
})
->sortable(),
SelectColumn::make('subject')
->options(SubjectClass::class)
->updateStateUsing(function (Page $livewire, $record) {
return $livewire->mountAction('updateSubject');
})
->sortable(),
This is my ListSubject page method
public function updateSubject()
{
return Actions\Action::make('updateSubject')
->action(fn () => dd('test'));
}
public function updateSubject()
{
return Actions\Action::make('updateSubject')
->action(fn () => dd('test'));
}
the dd test is work here but If I try to add ->requiresConfirmation() then it not work is there any way to use like this
Want results from more Discord servers?
Add your server