Get another field from selected relationship record

Is there a way (apart from another db fetch) to get a different field for the relationship record from a select dropdown? I've form fields like this:
Forms\Components\Select::make('category_id')
->relationship('category', 'name')
->required()
->live()
->afterStateUpdated(fn (Set $set, ?string $state) => $set('popular_category', $state < 10)),
Forms\Components\Toggle::make('popular_category')
->inline(false),
Forms\Compnents\TextInput::make('owner_name')
->visible(function (Get $get) {
//TODO: return true if category.owner_name is null
return true;
}),
Forms\Components\Select::make('category_id')
->relationship('category', 'name')
->required()
->live()
->afterStateUpdated(fn (Set $set, ?string $state) => $set('popular_category', $state < 10)),
Forms\Components\Toggle::make('popular_category')
->inline(false),
Forms\Compnents\TextInput::make('owner_name')
->visible(function (Get $get) {
//TODO: return true if category.owner_name is null
return true;
}),
Now, I wish to conditionally show owner_name field only if the selected category has its owner_name set as blank. Is there a way to do it without fetching the record from database?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server