Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radio button has problem #712

Open
sdvpnin opened this issue Jun 8, 2023 · 2 comments
Open

Radio button has problem #712

sdvpnin opened this issue Jun 8, 2023 · 2 comments
Labels

Comments

@sdvpnin
Copy link

sdvpnin commented Jun 8, 2023

        ->add('active', 'choice', [
            'label' => __('cruds.object.fields.active'),
            'choices' => ['yes' => 'Yes', 'no' => 'No'],
            'choice_options' => [
                'label_attr' => ['class' => 'label-class mx-1'],
            ],
            'selected' => 'no',
            'label_attr' => ['class' => 'col-md-2'],
            'expanded' => true,
            'multiple' => false
        ])

In model has yes value but it's selected no.
Add time work perfect with selected but edit time it's create the problem.so it's taking from selected attributes but not from the model
i try both
direct 'no' and with array also ['no']

@rudiedirkx rudiedirkx added the bug label Jun 8, 2023
@rudiedirkx
Copy link
Collaborator

rudiedirkx commented Jun 8, 2023

Can you put some debug in ChoiceType::buildCheckableChildren()? And maybe in CheckableType? To find out where the bug comes from. I never use choice fields, but rdx/laravel-form-builder-extras, so you're going to have to help me.

@ukeloop
Copy link
Contributor

ukeloop commented Jan 29, 2024

Model data is used only if the value property (value or selected) is NULL.
You can use default_value.

$this
    ->add('active', 'choice', [
        'choices' => ['yes' => 'Yes', 'no' => 'No'],
        'default_value' => 'no',
    ]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants