text input with relation
when i try to access pricing relation with product model, i could not access values in the form text input. can some one help me how to get relation model value with text input ???
TextInput::make('pricing.sell_price')
->label('Price')
->required()
->numeric()
->helperText('Enter price of the product')
->default(fn ($record) => $record?->pricing?->base_price),
product model
public function pricing(): HasOne
{
return $this->hasOne(ProductPricing::class);
}
3 Replies
Try explicitly passing the foreignkey on the hasOne method
`public function pricing(): HasOne
{
return $this-
>hasOne(ProductPricing::class, 'pricing_id');
}
Solution
You need to use a Layout field with
->relationship()
for thisi fixed it using group