Example
->add('housing', EntityType::class,
array(
'class' => 'AppBundle:Housing',
'choice_label' => 'housing',
'placeholder' => '',
'attr' => (in_array('Housing', $options['disabledOptions']) ? ['disabled' => 'disabled'] : []),
'label' => 'Housing: ',
'query_builder' => function (EntityRepository $er) use ($options) {
if (false === in_array('Housing', $options['disabledOptions'])) {
return $er->createQueryBuilder('h')
->orderBy('h.housing', 'ASC')
->where('h.enabled=1');
} else {
return $er->createQueryBuilder('h')
->orderBy('h.housing', 'ASC');
}
},
))