© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
sweetplum

how to load relationship() on Forms\Components\Fieldset conditionally?

The form uses
Forms\Components\Fieldset::relationship('primaryAddress')
Forms\Components\Fieldset::relationship('primaryAddress')
to load a related 'address' record of an user. but sometimes the user may not have the related address yet. In this case, it shows
Target [Illuminate\Database\Eloquent\Model] is not instantiable.
Target [Illuminate\Database\Eloquent\Model] is not instantiable.
error. Is there an way to load the related 'address' record condtionally?
I tried
->relationship('primaryAddress', function(Component $livewire) {
                        return (bool) $livewire->record->primaryAddress;
                    })
->relationship('primaryAddress', function(Component $livewire) {
                        return (bool) $livewire->record->primaryAddress;
                    })
, but I still get the error. thank you for your insights.
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

Fieldset relationship fields doesn't load data
FilamentFFilament / ❓┊help
3y ago
Nested Fieldset and relationship
FilamentFFilament / ❓┊help
3y ago
Forms\Components\Repeater::make('addresses')->relationship('addresses')
FilamentFFilament / ❓┊help
3y ago
conditionally showing relationship.
FilamentFFilament / ❓┊help
3y ago