F
Filament2mo ago
SirFat

HasOne not saving when using ->relationship() in a Group/Section/Fieldset

Hi, I'm wondering if I'm doing something silly or exercising futility on something that shouldn't work. I have a HasOne relationship on a model and I cannot get the data to save unless I use a repeater. I have not yet restructured the Forms to work in the new V4 Structure, but the structure is: CustomerResource -> Section (organisation (HasOne and saves)) -> OrganisationResource::baseForm -> Section (registrationName (HasOne and does not save)) -> TextInput
Repeater::make("regNumber")
->relationship('registrationNumber')
->saveRelationshipsWhenHidden()
->maxItems(1)
->hiddenLabel()
->addable(false)
->deletable(false)
->schema([
TextInput::make('number')->label("Registration Number")
->live()
->columnSpanFull()
->inlineLabel()
->required(),
])
->columns(4)
->columnSpan(1),
Repeater::make("regNumber")
->relationship('registrationNumber')
->saveRelationshipsWhenHidden()
->maxItems(1)
->hiddenLabel()
->addable(false)
->deletable(false)
->schema([
TextInput::make('number')->label("Registration Number")
->live()
->columnSpanFull()
->inlineLabel()
->required(),
])
->columns(4)
->columnSpan(1),
Does not work:
Section::make()
->relationship('registrationNumber')
->schema([
TextInput::make('number')->label("Registration Number")
->live()
->columnSpanFull()
->inlineLabel()
->required(),
])
->columns(4)
->columnSpan(1),
Section::make()
->relationship('registrationNumber')
->schema([
TextInput::make('number')->label("Registration Number")
->live()
->columnSpanFull()
->inlineLabel()
->required(),
])
->columns(4)
->columnSpan(1),
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?