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

add new class name to choice type is not working properly #606

Open
thanhtungka91 opened this issue Jul 10, 2020 · 1 comment
Open

add new class name to choice type is not working properly #606

thanhtungka91 opened this issue Jul 10, 2020 · 1 comment

Comments

@thanhtungka91
Copy link

I want to add a new class required to input filed but it was not working as expected, there is no required class is added to input field.

->add('del_flg', Field::CHOICE, [
                'label' => '削除状態',
                'choices' => ['0' => '有効', '1' => '削除済'],
                'expanded' => true,
                'multiple' => false,
                'attr' => ['class' => 'required'],
                'choice_options' => [
                    'wrapper' => ['class' => 'choice-wrapper'],
                    'label_attr' => ['class' => 'required label-class'],
                ],
            ]) 
@Eloar
Copy link
Contributor

Eloar commented Oct 11, 2022

have you tried to add it to 'choice_options'?

All you need to do is to move that class config one step up:

->add('del_flg', Field::CHOICE, [
                'label' => '削除状態',
                'choices' => ['0' => '有効', '1' => '削除済'],
                'expanded' => true,
                'multiple' => false,
                'class' => 'required',
                'choice_options' => [
                    'wrapper' => ['class' => 'choice-wrapper'],
                    'label_attr' => ['class' => 'required label-class'],
                ],
            ]) 

also required class is added when field has required validation rule set

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

No branches or pull requests

3 participants