Passing closure in viewData

In a Filament resource, I have some custom fields and right now im passing the record's data to the custom livewire view like this -

Forms\Components\View::make('engines')
                    ->viewData([
                        'formValues' => [
                            'title' => $form->getRecord()?->title,
                            'subtitle' => $form->getRecord()?->subtitle,
                            'button_text' =>$form->getRecord()?->button_text,
                            'content' => $form->getRecord()?->content,
                        ],

                    ])->visible(fn(string $operation) => $operation === 'edit')
                      ->columnSpanFull()


What i'd like to achieve is to make this component more granular so it will fit the create pages as well, which means that i need to pass the current data inside the form itself (from my experience - using
Get $get
), but the problem is that the
viewData
function is only receiving array and can't receive a Closure. How can i solve it? Thanks.
Was this page helpful?