I am using an entity type of form element in Symfony2's formbuilder.
->add('categories', 'entity', array('required' => false,
'multiple' => true,
'expanded' => true,
'label'=>'Categories (select all that apply)',
'class' => 'AcmeBundle:Category',
'query_builder' => function(EntityRepository $er) use ($profile) {
return $er->createQueryBuilder('u')
->where('u.profile = :profile')
->setParameter('profile', $profile)
->orderBy('u.name', 'ASC');
}));
There is a case where the database query does not return any values, but Symfony2 still displays the label for the element.
How do I suppress the label altogether for cases where there are no entity results to display? Thanks!