Toggle with eager loading in form

Why eager load works in table but not form? UserModel
public function notificationPreference(): HasOne
{
return $this->hasOne(UserNotificationPreference::class);
}
public function notificationPreference(): HasOne
{
return $this->hasOne(UserNotificationPreference::class);
}
UserResource
Forms\Components\Toggle::make('notificationPreference.is_enabled')
Forms\Components\Toggle::make('notificationPreference.is_enabled')
Is there any alternatives?
Solution:
Use ```php Group::make([ Toggle::make('is_enabled')...
Jump to solution
2 Replies
Solution
LeandroFerreira
Use
Group::make([
Toggle::make('is_enabled')
])->relationship('notificationPreference')
Group::make([
Toggle::make('is_enabled')
])->relationship('notificationPreference')
Lucky0
Lucky03d ago
Thank you, kind sire..
Forms\Components\Group::make([
Forms\Components\Toggle::make('is_enabled')
->label('Enable Notifications')
->formatStateUsing(fn ($record) => $record->is_enabled),
])
->relationship('notificationPreference'),
Forms\Components\Group::make([
Forms\Components\Toggle::make('is_enabled')
->label('Enable Notifications')
->formatStateUsing(fn ($record) => $record->is_enabled),
])
->relationship('notificationPreference'),