© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•16mo ago•
2 replies
Medo

Advanced Nested Relationship Form builder

I have EventStaff Model Thats HasOne EventStaffDetail using
staffDetails()
staffDetails()
method
    public function staffDetails(): HasOne
    {
        return $this->hasOne(EventStaffDetail::class)
            ->withDefault();
    }
    public function staffDetails(): HasOne
    {
        return $this->hasOne(EventStaffDetail::class)
            ->withDefault();
    }


Inside EventStaffDetail Model I have
positions()
positions()
method thats morphToMany StaffPosition
    public function positions()
    {
        return $this->morphToMany(StaffPosition::class, 'positionable')
            ->withPivot('staff_position_id')
            ->withTimestamps();
    }
    public function positions()
    {
        return $this->morphToMany(StaffPosition::class, 'positionable')
            ->withPivot('staff_position_id')
            ->withTimestamps();
    }


So From EventStaffResource Iam able to point to staffDetails Relation by passing relationship method to section

            Section::make()->schema([
                Wizard::make()
                    ->schema([
                        Wizard\Step::make(__('Information About you'))
                            ->schema([
                                Section::make(__('Positions'))
                                    ->description(__('Which position(s) most interests you?'))
                                    ->schema([
                                        Repeater::make('positions')
                                            ->relationship('positions')
                                            ->schema([
                                                Select::make('staff_position_id')
                                                ->label('Position')
                                                    ->options(StaffPosition::all()->pluck('title', 'id')->toArray())
                                                    ->searchable()
                                                    ->required(),
                                            ]),
                                    ])
                                    ->columnSpan(1),
                            ])
                    ])
                    ->contained(false)
                    ->skippable(),
            ])->relationship('staffDetails')
            Section::make()->schema([
                Wizard::make()
                    ->schema([
                        Wizard\Step::make(__('Information About you'))
                            ->schema([
                                Section::make(__('Positions'))
                                    ->description(__('Which position(s) most interests you?'))
                                    ->schema([
                                        Repeater::make('positions')
                                            ->relationship('positions')
                                            ->schema([
                                                Select::make('staff_position_id')
                                                ->label('Position')
                                                    ->options(StaffPosition::all()->pluck('title', 'id')->toArray())
                                                    ->searchable()
                                                    ->required(),
                                            ]),
                                    ])
                                    ->columnSpan(1),
                            ])
                    ])
                    ->contained(false)
                    ->skippable(),
            ])->relationship('staffDetails')
image.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Advanced - Form Builder
FilamentFFilament / ❓┊help
3y ago
Nested relationship form data not loading
FilamentFFilament / ❓┊help
3mo ago
advanced form
FilamentFFilament / ❓┊help
3y ago
form builder
FilamentFFilament / ❓┊help
2y ago