© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
2 replies
GavTheDev

Select HasMany relationship with CreateOption

According to the docs the ability to create a new option on the fly only supports
BelongsTo
BelongsTo
and
BelongsToMany
BelongsToMany
relations, but my use-case is a
HasMany
HasMany
. I have been experimenting but nothing seems to work unfortunately. How can I get a HasMany to work?

What I am trying to achieve is a checkout form where an authed user can select a shipping address, and if it does not exist they could create one on the fly.

Select::make('addresses')
     ->label(__('Shipping Address'))
     ->relationship(
           name: 'auth.user.addresses', // Tried 'addresses`, 'user.addresses`, 'auth.user.addresses`, 
           titleAttribute: 'addres_line'
    )
    ->preload()
    ->searchable(false)
    ->createOptionForm([
        TextInput::make('line_one')
             ->required(),
        ])
Select::make('addresses')
     ->label(__('Shipping Address'))
     ->relationship(
           name: 'auth.user.addresses', // Tried 'addresses`, 'user.addresses`, 'auth.user.addresses`, 
           titleAttribute: 'addres_line'
    )
    ->preload()
    ->searchable(false)
    ->createOptionForm([
        TextInput::make('line_one')
             ->required(),
        ])
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

Select with hasMany?
FilamentFFilament / ❓┊help
3y ago
HasMany relationship
FilamentFFilament / ❓┊help
3y ago
Form with HasMany Relationship?
FilamentFFilament / ❓┊help
3y ago
Repeater with hasMany relationship
FilamentFFilament / ❓┊help
3y ago