© 2026 Hedgehog Software, LLC

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

Select multiple preloaded options are reordered after selecting the input

I have a select multiple that is formFilled with options already attached on a BelongsToMany relationship. As you can see in the attached gif, the options are visible when the form is shown, but when you click the select input the options are rearranged alphabetically. Is there a way to prevent this or to load the options in already sorted so it doesn't jump on the user?

My code:

Tables\Actions\Action::make('manageCollections')
    ->label('Manage collections')
    ->icon('heroicon-o-rectangle-stack')
    ->modalIcon('heroicon-o-rectangle-stack')
    ->modalWidth(MaxWidth::Small)
    ->fillForm(fn (Account $account) => $account->collections()->mine()->get()->all())
    ->form([
        Forms\Components\Select::make('collections')
            ->label('Collections')
            ->multiple()
            ->relationship(
                'collections',
                'name',
                fn (Builder $query) => $query->mine())->preload(),
    ])
    ->after(
        fn () => Notification::make()
            ->success()
            ->title('Saved successfully')
            ->body('Changes to the account have been saved.')
            ->send()
    ),
Tables\Actions\Action::make('manageCollections')
    ->label('Manage collections')
    ->icon('heroicon-o-rectangle-stack')
    ->modalIcon('heroicon-o-rectangle-stack')
    ->modalWidth(MaxWidth::Small)
    ->fillForm(fn (Account $account) => $account->collections()->mine()->get()->all())
    ->form([
        Forms\Components\Select::make('collections')
            ->label('Collections')
            ->multiple()
            ->relationship(
                'collections',
                'name',
                fn (Builder $query) => $query->mine())->preload(),
    ])
    ->after(
        fn () => Notification::make()
            ->success()
            ->title('Saved successfully')
            ->body('Changes to the account have been saved.')
            ->send()
    ),


I've also tried adding
->orderBy('name')
->orderBy('name')
to the formFill query without success. Any ideas?
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

Event after table items are reordered
FilamentFFilament / ❓┊help
6mo ago
Selecting all values in Select::multiple
FilamentFFilament / ❓┊help
3y ago
Dependant select with multiple options
FilamentFFilament / ❓┊help
3y ago
Combining preloaded options and search results in Forms\Components\Select
FilamentFFilament / ❓┊help
2y ago