0

I am working on a Symfony form where it must have a dropdown with checkboxes to select multiple values. However choice and entity input types have 'multiple' and 'expanded' attributes which cannot produce what I need. Shown below is my requirement.

enter image description here

Here's how my form is:

$form = $this->createFormBuilder()
    ->add('features', 'choice', array('choices'=>array('a','b','c'), 'multiple'=> true))
    ->getForm();

Above code produces an expanded dropdown with a multi select.

Teshan N.
  • 2,307
  • 3
  • 30
  • 59

2 Answers2

1

you have to use a JS library like https://github.com/ehynds/jquery-ui-multiselect-widget.

You can find the answer here : How to use Checkbox inside Select Option

loic
  • 36
  • 3
0

for creating check box with opportunity check one box, you can use this

        $builder
        ->add('check_box', ChoiceType::class, [
            'label' => 'status',
            'multiple' => false,
            'expanded' => false,
            'choices' => [a, b, c],
            'translation_domain' => 'common',
            'label_attr' => ['class' => 'cursor_text'],
            'attr' => [
                'style' => 'some style'
            ]
        ]);
shuba.ivan
  • 3,824
  • 8
  • 49
  • 121