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')


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 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;
    }
Was this page helpful?