© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
8 replies
Baspa

How to populate multi select list with default selected values

I have this multiple select form field where I load the options and try to set the default values:

Forms\Components\Select::make('platforms')
    ->options(function () {
        return Platform::query()
            ->get()
            ->mapWithKeys(fn ($platform) => [$platform->id => $platform->name]);
    })
    ->label(__('Platforms'))
    ->default(function () {
        return ChannelPlatformFrequency::query()
        ->where('channel_id', request()->route('record'))
        ->get()
        ->mapWithKeys(fn ($channelPlatformFrequency) => [$channelPlatformFrequency->platform_id => $channelPlatformFrequency->platform->name]);
    })
    ->multiple()
    ->required(),
Forms\Components\Select::make('platforms')
    ->options(function () {
        return Platform::query()
            ->get()
            ->mapWithKeys(fn ($platform) => [$platform->id => $platform->name]);
    })
    ->label(__('Platforms'))
    ->default(function () {
        return ChannelPlatformFrequency::query()
        ->where('channel_id', request()->route('record'))
        ->get()
        ->mapWithKeys(fn ($channelPlatformFrequency) => [$channelPlatformFrequency->platform_id => $channelPlatformFrequency->platform->name]);
    })
    ->multiple()
    ->required(),


The
default
default
method does not seem to work. It does not show any selected options. As far as I know I should use the
default
default
option to set the default selected values. As you can see in the image I attached the available options (up) and the default values (down) should match.
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

Testing select list values
FilamentFFilament / ❓┊help
2y ago
Select menu. Enum. How set default-selected
FilamentFFilament / ❓┊help
2y ago
Default select not being selected
FilamentFFilament / ❓┊help
3y ago
How to populate select list options without pre-selecting them?
FilamentFFilament / ❓┊help
2y ago