Reputation: 3
public static function table(Table $table): Table
{
return $table
->columns([
ImageColumn::make('sns_icon')->visibility('private'),
TextColumn::make('sns_title')
->searchable()
->sortable(),
TextColumn::make('link')
->limit(50)
->sortable(),
TextColumn::make('order')
->sortable(),
ToggleColumn::make('is_active')
->onIcon('heroicon-m-check')
->offIcon('heroicon-m-x-mark')
->action(function (SnsButton $record, $state) {
return fn() => $record->update([
'is_active' => $state
]);
})
->beforeStateUpdated(function (SnsButton $record, $state) {
return fn() =>
$record->is_active = $state;
})
->afterStateUpdated(function (SnsButton $record) {
Notification::make()
->title('Status Updated')
->body('SNS Button status has been changed.')
->success()
->send();
}),
])
I'm using the Filament component library and I've created a switch column in my table. However, when the switch is clicked, it immediately updates the is_active value without any confirmation.
I want to add a confirmation dialog before is_active field is updated. How can I achieve this?
Upvotes: 0
Views: 70