Morphed table not filling in form

I don't seem to be able to fill the value of a morphed column in the formview. I have the following relation;
public function sellingPoint(): MorphOne
{
return $this->morphOne(SellingPoint::class, 'morph');
}
public function sellingPoint(): MorphOne
{
return $this->morphOne(SellingPoint::class, 'morph');
}
When I try to access this inside a form, it never gets filled with a value. I try to access ti this way;
Forms\Components\TextInput::make('sellingPoint.name')
->reactive()
->afterStateUpdated(function (?VendingMachine $record, $state) {
$record?->sellingPoint?->update([
'name' => $state
]);
}),
Forms\Components\TextInput::make('sellingPoint.name')
->reactive()
->afterStateUpdated(function (?VendingMachine $record, $state) {
$record?->sellingPoint?->update([
'name' => $state
]);
}),
Then the input field never gets it's value. However saving works (due to that after state updated callback). In the table view it works just fine;
Tables\Columns\TextColumn::make('sellingPoint.name')->label('Name')->searchable(),
Tables\Columns\TextColumn::make('sellingPoint.name')->label('Name')->searchable(),
What am I missing here?
4 Replies
Dan Harrin
Dan Harrin2y ago
dot syntax is not used for relationships in the form builder
Robin
RobinOP2y ago
But I don't want it in a fieldset
Dan Harrin
Dan Harrin2y ago
you dont need a fieldset
You may load and save the contents of a layout component
fieldset, grid, group, card, anything this is part of the layout docs generally, not the fieldset docs
Want results from more Discord servers?
Add your server