© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•6mo 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),
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

CheckboxList inside a Fieldset not saving relationship
FilamentFFilament / ❓┊help
13mo ago
Do not save or exclude Fieldset->relationship() when saving a form?
FilamentFFilament / ❓┊help
3y ago
Form HasOne relationship
FilamentFFilament / ❓┊help
3y ago
relationship datetime property not hydrated when in relationship group
FilamentFFilament / ❓┊help
7mo ago