© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
GeRaged | Niklas

How to preselect a CheckboxList

Hey, how is it possible to preselect some values on a CheckboxList I already tried the
->default([{"10":"Test"}])
->default([{"10":"Test"}])
but this does not work.

This is the complete code

Section::make('Attribute')
    ->schema(
        self::getAttributeData(Resort::class)
            ->map(fn($attributes, $group) =>
            CheckboxList::make($group)
                ->statePath('attributes')
                ->options(fn () => $attributes)
                ->default(fn (Resort $record) => $record->attributes()->pluck('name', 'id'))
            )->toArray()
    )
    ->columns(3)
Section::make('Attribute')
    ->schema(
        self::getAttributeData(Resort::class)
            ->map(fn($attributes, $group) =>
            CheckboxList::make($group)
                ->statePath('attributes')
                ->options(fn () => $attributes)
                ->default(fn (Resort $record) => $record->attributes()->pluck('name', 'id'))
            )->toArray()
    )
    ->columns(3)
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

How to preselect a MorphToSelect?
FilamentFFilament / ❓┊help
6mo ago
Preselect table Bulk
FilamentFFilament / ❓┊help
17mo ago
CheckBoxList
FilamentFFilament / ❓┊help
3y ago
How to add tooltip to CheckboxList component
FilamentFFilament / ❓┊help
2y ago