How to get current record on Table action using a custom form field

Hi,

I have a Resource with a Table action using a custom field. I need pass data to the view for this action - all works well for user details but how do I pass the current record’s ID? I’ve tried lots of approaches but it never passes the data

// Resource class action $table actions
Tables\Actions\Action::make('Publish')
    ->form([
        BraintreePayment::make('Billing details')
            ->viewData([
                'first_name' => auth()->user()->first_name,
                ...
                'payment' => [
                    'type' => 'publish',
                    // 'record_id' => fn (Model $record) => $record,
                    'record_id' => fn ($form) => $form->getRecord(),  // $record->id,
                ]
            ])
    ])


I know I can get the record in my BraintreePayment Blade using recordId: '{{ $getRecord()->id }}' but this doesn’t work for me as I want to pass in an object of data to make the component describing the type of payment being made more reusable for different situations.
Was this page helpful?