Toggle column issue.

Toggling one record changes other records.
Tables\Columns\ToggleColumn::make('published')
->label('Publish')
->onColor('success')
->alignCenter()
->tooltip(fn(News $record) => $record->published
? 'Unpublish' : 'Publish'),
Tables\Columns\ToggleColumn::make('published')
->label('Publish')
->onColor('success')
->alignCenter()
->tooltip(fn(News $record) => $record->published
? 'Unpublish' : 'Publish'),
6 Replies
wyChoong
wyChoong2y ago
Don’t think toggle column by default deal with non Boolean You might need to handle the state yourself
Darpan
DarpanOP2y ago
It's a boolean column,
$table->boolean('published')->default(false);
$table->boolean('published')->default(false);
Darpan
DarpanOP2y ago
This also happen with table action.
Tables\Actions\Action::make('published')
->icon(fn(News $record) => $record->published ? 'heroicon-o-x' : 'heroicon-o-check')
->color(fn(News $record) => $record->published ? 'danger' : 'success')
->label(fn(News $record) => $record->published ? 'Unpublish' : 'Publish')
->action(fn(News $record) => $record->update(['published' => !$record->published])),
Tables\Actions\Action::make('published')
->icon(fn(News $record) => $record->published ? 'heroicon-o-x' : 'heroicon-o-check')
->color(fn(News $record) => $record->published ? 'danger' : 'success')
->label(fn(News $record) => $record->published ? 'Unpublish' : 'Publish')
->action(fn(News $record) => $record->update(['published' => !$record->published])),
Darpan
DarpanOP2y ago
Sometimes it keeps sending requests
toeknee
toeknee2y ago
This is a known bug we haven't been able to solve, it's caused by a recent change to fix bulk changes on toggles allowing them to update. The downside is when changing toggles very fast it creates an infinite loop fyi @Dan Harrin
Kenneth Sese
Kenneth Sese2y ago
Hi! I just PRed a fix that hopefully solves Toggle column issues. Could you test it against your app and see if it fixes them there too? https://github.com/filamentphp/filament/pull/6221
GitHub
Fixes all toggle column problems by archilex · Pull Request #6221 ·...
I think I got it! Like I had mentioned previously I think alpine's init watcher was causing the issue so I rewrote the code without using it. This version solves ALL the problems listed in Issu...

Did you find this page helpful?