© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
4 replies
Remi

Repeater based on other iterations

I want to create a repeater that allows a user to attach multiple locations, but every locations only once.

so far i got this:
Forms\Components\Repeater::make('clientLocations')
                    ->label(__('Locations'))
                    ->live()
                    ->relationship()
                    ->orderColumn('order')
                    ->simple(
                        Forms\Components\Select::make('location_id')
                            ->live()
                            ->relationship('location', 'name')
                            ->required()
                    ),
Forms\Components\Repeater::make('clientLocations')
                    ->label(__('Locations'))
                    ->live()
                    ->relationship()
                    ->orderColumn('order')
                    ->simple(
                        Forms\Components\Select::make('location_id')
                            ->live()
                            ->relationship('location', 'name')
                            ->required()
                    ),


This allows me to create multiple attachments, but i can attach every location multiple times.

i got this far, but this removes all the attached locations

Forms\Components\Repeater::make('clientLocations')
                    ->label(__('Locations'))
                    ->live()
                    ->relationship()
                    ->orderColumn('order')
                    ->simple(
                        Forms\Components\Select::make('location_id')
                            ->live()
                            ->relationship('location', 'name', function (Builder $query, Get $get) {
                                Log::info(json_encode($get('../../clientLocations')));
                                return $query->whereNotIn('id',array_column($get('../../clientLocations'), 'location_id'));
                            })
                            ->required()
                    ),
Forms\Components\Repeater::make('clientLocations')
                    ->label(__('Locations'))
                    ->live()
                    ->relationship()
                    ->orderColumn('order')
                    ->simple(
                        Forms\Components\Select::make('location_id')
                            ->live()
                            ->relationship('location', 'name', function (Builder $query, Get $get) {
                                Log::info(json_encode($get('../../clientLocations')));
                                return $query->whereNotIn('id',array_column($get('../../clientLocations'), 'location_id'));
                            })
                            ->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

Questions based on repeater
FilamentFFilament / ❓┊help
2y ago
Change repeater field label based on other field value
FilamentFFilament / ❓┊help
16mo ago
Repeater based on user input
FilamentFFilament / ❓┊help
3y ago
Dynamic Repeater based on FileUpload->multiple() files
FilamentFFilament / ❓┊help
15mo ago