在我的表单生成器中,我正在尝试使用这个
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('u')
if(var)
->where('u.id = 3')
'query_builder' => function(EntityRepository $er) {
$qb = $er->createQueryBuilder('u');
if ($someCondition) {
$qb->where('u.id = 3');
}
return $qb;
}