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.
                                })

Any help.I want to access the $records inside the afterStateUpdated() closure.
Was this page helpful?