© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
3 replies
prowler

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()
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
Get $get
), but the problem is that the
viewData
viewData
function is only receiving array and can't receive a Closure. How can i solve it? Thanks.
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

custom field viewData closure returns empty always
FilamentFFilament / ❓┊help
2y ago
closure in badgeColumn colors
FilamentFFilament / ❓┊help
3y ago
Relation Manager Closure In Table
FilamentFFilament / ❓┊help
3y ago
ViewField -> ViewData variable not available
FilamentFFilament / ❓┊help
3mo ago