© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•6mo ago•
1 reply
jamesro

belongsToMany select for relation not working

anyone knows what I'm doing wrong in this Select field with relation BelongsToMany using pivot table

public function users()
{
return $this->belongsToMany(User::class, 'section_users', 'id_section, 'user_id');
}

in my form I have:
Select::make('users')
                    ->searchable()
                    ->live(onBlur: true)
                    ->multiple()
                    ->relationship(
                        'users',
                        'nume',
                        modifyQueryUsing: fn (Builder $query, Get $get) => $query->where('disabled', 0)
                    )
                    ->preload()
                    ->required(),
Select::make('users')
                    ->searchable()
                    ->live(onBlur: true)
                    ->multiple()
                    ->relationship(
                        'users',
                        'nume',
                        modifyQueryUsing: fn (Builder $query, Get $get) => $query->where('disabled', 0)
                    )
                    ->preload()
                    ->required(),


i can select users in the field, but when i save the form, the relation is not saved, works just fine if i use a relation manager for that relation
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

Dependant select with BelongsToMany relation
FilamentFFilament / ❓┊help
3y ago
Using Select with a BelongsToMany relation
FilamentFFilament / ❓┊help
3y ago
BelongsToMany relation issue
FilamentFFilament / ❓┊help
3y ago
Select is not working for a BelongsToMany relationship in RelationManager
FilamentFFilament / ❓┊help
2y ago