Accessing the selected records before firing a bulk action

Hello, is it possible to access the selected records somehow before firing a bulk action, maybe using javascript or if there is a function that let's me access them as soon as i select them?
3 Replies
charlie
charlie3w ago
Hi, you could do this for example with a custom BulkAction:
BulkAction::make('bulkEdit')
->name('My action')
->icon('heroicon-o-pencil')
->form([
Select::make('a_select_field')
])
->action(function (Collection $records, array $data) {
$data = array_filter($data);
return $records->each->update($data);
})
->deselectRecordsAfterCompletion(),
BulkAction::make('bulkEdit')
->name('My action')
->icon('heroicon-o-pencil')
->form([
Select::make('a_select_field')
])
->action(function (Collection $records, array $data) {
$data = array_filter($data);
return $records->each->update($data);
})
->deselectRecordsAfterCompletion(),
You also have the before() method:
Tables\Actions\DeleteBulkAction::make()
->before(function (Collection $records) {
// ...
})
Tables\Actions\DeleteBulkAction::make()
->before(function (Collection $records) {
// ...
})
Nikos Koukos
Nikos KoukosOP3w ago
actually i want to access the selected records before i click the action, before is not working until i click the the bulk action
charlie
charlie3w ago
oh gotcha

Did you find this page helpful?