F
Filament15mo ago
Robin

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 Harrin15mo ago
dot syntax is not used for relationships in the form builder
Robin
Robin15mo ago
But I don't want it in a fieldset
Dan Harrin
Dan Harrin15mo 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
More Posts
how can i add extra text to modal, which is a link, and a text like a note in filament import?how can i add extra text to modal, which is a link, and a text like a note in filament import?Nested filters and filterTable() testingAll i wanted was to create some layout changes in my filters by using a fieldset. Unfortunately thatIs there is a way to add loader or spinner in reactive fields ?i am using reactive function for fields to visible on specific state value when i select the values How to set the record url on a resource tableWhen using the Table builder, we can set the record url using `getTableRecordUrlUsing()` (https://fFilter relation manager when clic in his parentHi, it is posible to apply a filter in a relation manager when clic his parent in another relation mTo to plug attribute from preloadRecordSelect RelationManagerIs there a way to pluck out a different column from the preload function below instead of having theClose all notificationsIs there a way to trigger the close event on any persisted notifications?Permission denied when uploading images, PDFs work.I am using `SpatieMediaLibraryFileUpload` to upload PDF's and images I added `acceptedFileTypes(['Need Help Creating a Publish At Field and Choosing a Category PackageHi, I have a question about creating a publish at field. Is there a package that can be used to creHow can i modify a table record column before save (on column input)I have a toggle column on my table - when i toggle this column like to modify another columns data b