© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
10 replies
Jon Mason

Radio default not working

I have a Radio input in my form and using default isn't working for some reason:

Radio::make('access_option')
                        ->default('specific')
                        ->options([
                            'all' => 'All Locations',
                            'specific' => 'Specific locations',
                            'copy' => 'Copy location access from user',
                            'team' => 'Add all from specific team'
                        ])
                        ->required()
                        ->live()
                        ->afterStateUpdated(fn (Radio $component) => $component
                            ->getContainer()
                            ->getComponent('dynamicTypeFields')
                            ->getChildComponentContainer()
                            ->fill()),
                    Grid::make(2)
                        ->schema(fn (Get $get): array => match ($get('access_option')) {
                            ...
                        })->key('dynamicTypeFields')
Radio::make('access_option')
                        ->default('specific')
                        ->options([
                            'all' => 'All Locations',
                            'specific' => 'Specific locations',
                            'copy' => 'Copy location access from user',
                            'team' => 'Add all from specific team'
                        ])
                        ->required()
                        ->live()
                        ->afterStateUpdated(fn (Radio $component) => $component
                            ->getContainer()
                            ->getComponent('dynamicTypeFields')
                            ->getChildComponentContainer()
                            ->fill()),
                    Grid::make(2)
                        ->schema(fn (Get $get): array => match ($get('access_option')) {
                            ...
                        })->key('dynamicTypeFields')


Once I select an option everything works as expected, but on page load the default isn't there.
Solution
Your comment got me on the right track. Found a github answer that indicated I need to set the value of the
access_option
access_option
array key before the form is filled, so I added this to my EditUser resource and now its working as expected:

    protected function mutateFormDataBeforeFill(array $data): array
    {
        $data['access_option'] = 'specific';
        
        return $data;
    }
    protected function mutateFormDataBeforeFill(array $data): array
    {
        $data['access_option'] = 'specific';
        
        return $data;
    }
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Radio default not working on form widget
FilamentFFilament / ❓┊help
3y ago
Default selection for radio element - not working!
FilamentFFilament / ❓┊help
3y ago
Default selection for radio element - not working!
FilamentFFilament / ❓┊help
3y ago
setting radio default value on form builder not working, but on resource its working
FilamentFFilament / ❓┊help
3y ago