F
Filament12mo ago
Azorky

BUG: Bulk action in table widget not working

I have a bulk action in my tablewidget with this code:
No description
6 Replies
Azorky
AzorkyOP12mo ago
I'm only selecting 1 record, but when I dump the $records, it's showing records that were not selected as well
No description
No description
Azorky
AzorkyOP12mo ago
Another example:
No description
No description
Azorky
AzorkyOP12mo ago
Am I doing something wrong? Or could this be a bug with the BulkActions? Bump 😬
Jordy
Jordy12mo ago
its already a deletebulkaction so no need to actually change the action?
Azorky
AzorkyOP12mo ago
Correct, I only changed the action so see which records it selects with the dd(). Because even without modifying it, I only selected one, and it deleted all of them
DrByte
DrByte12mo ago
I have Filament 3.1.28 installed and when I use the Bulk actions, only the selected records are processed.
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\BulkAction::make('export-selected')
->label('Export Selected')
->color('secondary')
->icon('heroicon-s-arrow-down-tray')
->action(fn (Collection $records) => (new MembersExport)
->forRecords($records)
->download('members-export-' . date('Y-m-d-h-i-s') . '.xlsx'))
->successNotificationTitle('Exported. Check your downloads directory.'),
]),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\BulkAction::make('export-selected')
->label('Export Selected')
->color('secondary')
->icon('heroicon-s-arrow-down-tray')
->action(fn (Collection $records) => (new MembersExport)
->forRecords($records)
->download('members-export-' . date('Y-m-d-h-i-s') . '.xlsx'))
->successNotificationTitle('Exported. Check your downloads directory.'),
]),
])
I just tested afresh: Both my Export and Delete are only deleting/exporting the selected record (I tried 1, 2, 4 records, all did as expected, never with unexpected records).
Want results from more Discord servers?
Add your server