Make bulk action reactive to selection

Is it possible to check the selection to make a bulk action disabled/enabled? For example, if there are rows in selection do not have 'tracking_number', the 'Send' bulk-action is disabled
6 Replies
IndomieRendang
IndomieRendangOP2y ago
Thanks for your help. But this is another case, I want to disable the action, not the select box. Because I have several bulk actions and one of them need additional criteria to make it enabled I hope there is ->disabled(fn ($records) => // check each record)
toeknee
toeknee2y ago
To remove the selection per record you can use: https://filamentphp.com/docs/2.x/tables/actions#disabling-record-bulk-actions To disable the bulk action in checked the records do:
->disabled(fn($records) => $records->contains(fn($record) => $record->isLocked()))
->disabled(fn($records) => $records->contains(fn($record) => $record->isLocked()))
For example
Filament
Actions - Table Builder - Filament
The elegant TALL stack table builder for Laravel artisans.
IndomieRendang
IndomieRendangOP2y ago
Well, it looks work but not visually disabled, and to make it from disabled to enabled after changing selection, I need two clicks for that action to work again (first click it still disabled, second click already enabled and work), I guess it was to update the state from the server The clearer effect can be seen using hidden
toeknee
toeknee2y ago
Not quite sure I follow. You could also the extraAttributes method too.
IndomieRendang
IndomieRendangOP2y ago
Alright thanks anyway... I've found the alternative using disabledForm... feels more informative than disabled the action itself
Want results from more Discord servers?
Add your server