© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
5 replies
lodeki

Access BulkAction $record inside a form field closure

 BulkAction::make('Send Invoice')->icon('heroicon-o-template')->deselectRecordsAfterCompletion()->action(function (Collection $records) {
dd($records); //the records populate as expected 
                })->form(
                    function (Collection $records) {
dd($records) ; //gives the selected records
                        return [
                            Card::make()->schema([
                                Radio::make('invoice_type')->options(function () {
                                    $utils = [];
                                    $utilities = Utility::pluck('utility_name');

                                    if ($utilities->isNotEmpty()) {
                                        foreach ($utilities as $key => $value) {
                                            $utils[$value] = $value;
                                        }
                                        return array_merge($utils, ['Standard' => 'Standard', 'Rent' => 'Rent']);
                                    } else {
                                        return [
                                            'Standard' => 'Standard',
                                            'Rent' => 'Rent'
                                        ];
                                    }
                                })->inline()->required()->reactive()->afterStateUpdated(function($state,Collection $records) {
dd($records); //ERROR:: EMPTY COLLECTION
//I want to access the $records here.
                                })
 BulkAction::make('Send Invoice')->icon('heroicon-o-template')->deselectRecordsAfterCompletion()->action(function (Collection $records) {
dd($records); //the records populate as expected 
                })->form(
                    function (Collection $records) {
dd($records) ; //gives the selected records
                        return [
                            Card::make()->schema([
                                Radio::make('invoice_type')->options(function () {
                                    $utils = [];
                                    $utilities = Utility::pluck('utility_name');

                                    if ($utilities->isNotEmpty()) {
                                        foreach ($utilities as $key => $value) {
                                            $utils[$value] = $value;
                                        }
                                        return array_merge($utils, ['Standard' => 'Standard', 'Rent' => 'Rent']);
                                    } else {
                                        return [
                                            'Standard' => 'Standard',
                                            'Rent' => 'Rent'
                                        ];
                                    }
                                })->inline()->required()->reactive()->afterStateUpdated(function($state,Collection $records) {
dd($records); //ERROR:: EMPTY COLLECTION
//I want to access the $records here.
                                })

Any help.I want to access the $records inside the afterStateUpdated() closure.
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

undefined record inside bulkAction
FilamentFFilament / ❓┊help
3y ago
How to access parent record inside repeater field?
FilamentFFilament / ❓┊help
3y ago
BulkAction with polling within action closure
FilamentFFilament / ❓┊help
3y ago
Access record in form method
FilamentFFilament / ❓┊help
3y ago