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(),


The default method does not seem to work. It does not show any selected options. As far as I know I should use the 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.
Was this page helpful?