I have a form widget of type "choice" which is being displayed as a list of many checkboxes. Everything works great. So to stress it out: there is ONE widget, with MANY checkboxes (and NOT several checkbox widgets).
Now, I want to disable some of those checkboxes. The data for that is avaliable in the $options-Array.
Here is the buildForm()-function of my FooType.php
...
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('foo', 'choice', array('choices' => $options['choiceArray']['id'],
'multiple' => true,
'expanded' => true,
'disabled' => $options['choiceArray']['disabled'] // does not work (needs a boolean)
'data' => $options['choiceArray']['checked'], // works
'attr' => array('class' => 'checkbox')))
;
}
...
My Twig-template looks like this:
{% for foo in fooForm %}
<dd>{{ form_widget(foo) }}</dd>
{% endfor %}
I can only disable ALL the checkboxes (by setting 'disabled' => true in buildForm). And passing an array there does not work (as commented in the snippet).
How can I disable some selected checkboxed (stored in $options['choiceArray']['disabled']) of my choice widget?