Not Loading Data from Fieldset->relationship()

I have a Fieldset with hasOne relationship() and my form schema(), like here:
Select::make('metadata_id')
->relationship(name: 'metadata', titleAttribute: 'title')

Fieldset::make('Metadata')
->relationship('metadata')
->schema([
TextInput::make('title'),
Textarea::make('description'),
FileUpload::make('image'),
])->disabled()
Select::make('metadata_id')
->relationship(name: 'metadata', titleAttribute: 'title')

Fieldset::make('Metadata')
->relationship('metadata')
->schema([
TextInput::make('title'),
Textarea::make('description'),
FileUpload::make('image'),
])->disabled()
The form has ->disabled() because I only want it to show the data. I selected the correct one in the Select-field and saved the form. But after reloading the page it does not load the data.
Solution:
I changed it to belongsTo relationship, now it works πŸ‘
Jump to solution
5 Replies
LH
LHβ€’9mo ago
@_𝕰𝖋x Don't know if it will work, but you can try this
Select::make(metadata.title)
Select::make(metadata.title)
_𝕰𝖋x
_𝕰𝖋xOPβ€’9mo ago
no, it still doesn't work 😦 But thanks anyway
LH
LHβ€’9mo ago
@_𝕰𝖋x your hasOne relation method in model class - it is named 'metadata' right?
_𝕰𝖋x
_𝕰𝖋xOPβ€’9mo ago
yes
public function metadata(): HasOne {
return $this->hasOne(Metadata::class);
}
public function metadata(): HasOne {
return $this->hasOne(Metadata::class);
}
Solution
_𝕰𝖋x
_𝕰𝖋xβ€’9mo ago
I changed it to belongsTo relationship, now it works πŸ‘
Want results from more Discord servers?
Add your server