© 2026 Hedgehog Software, LLC

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

Repeater reordering violates unique constraint

Hi, I try to reorder my items and SQL throws violates unique constraint. When i clone a item it works but not when i reorder.

Filament: 3.0.86

My code:

Forms\Components\Repeater::make('days')
                    ->relationship()
                    ->label('Days')
                    ->cloneable()
                    ->collapsible()
                    ->collapsed()
                    ->orderColumn('day')
                    ->reorderableWithButtons()
                    ->itemLabel(function (array $state) {
                        $labels = [];

                        if (isset($state['day']) && $state['day']) {
                            $labels[] = 'Day ' . $state['day'];
                        }

                        if (isset($state['nutrients']) && count($state['nutrients'])) {
                            $labels[] = "N" . count($state['nutrients']);
                        }

                        if (isset($state['oncePerDayNutrients']) && count($state['oncePerDayNutrients'])) {
                            $labels[] = "O" . count($state['oncePerDayNutrients']);
                        }

                        if (isset($state['lights']) && count($state['lights'])) {
                            $labels[] = "L" . count($state['lights']);
                        }

                        return count($labels) ? implode(' | ', $labels) : null;
                    })
Forms\Components\Repeater::make('days')
                    ->relationship()
                    ->label('Days')
                    ->cloneable()
                    ->collapsible()
                    ->collapsed()
                    ->orderColumn('day')
                    ->reorderableWithButtons()
                    ->itemLabel(function (array $state) {
                        $labels = [];

                        if (isset($state['day']) && $state['day']) {
                            $labels[] = 'Day ' . $state['day'];
                        }

                        if (isset($state['nutrients']) && count($state['nutrients'])) {
                            $labels[] = "N" . count($state['nutrients']);
                        }

                        if (isset($state['oncePerDayNutrients']) && count($state['oncePerDayNutrients'])) {
                            $labels[] = "O" . count($state['oncePerDayNutrients']);
                        }

                        if (isset($state['lights']) && count($state['lights'])) {
                            $labels[] = "L" . count($state['lights']);
                        }

                        return count($labels) ? implode(' | ', $labels) : null;
                    })
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

Reordering repeater items
FilamentFFilament / ❓┊help
2y ago
Repeater without reordering buttons
FilamentFFilament / ❓┊help
3y ago
Repeater unique field
FilamentFFilament / ❓┊help
3y ago
Repeater reordering not working on relationship
FilamentFFilament / ❓┊help
3y ago