I am using sonataAdminBundle and symfony2
I made this script. it filter the search box candidates.
but this query_builder is ignored.
Are there any other points to check ?
public function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('user',null,
array(
'query_builder' =>
function (\Doctrine\ORM\EntityRepository $rep) {
return $rep->
createQueryBuilder('s')
->where('s.id','1');
})
adding...
I am using this script for new entry,it works
$formMapper
->with('General')
->add('teacher',
null,
array(
'query_builder' =>
function (\Doctrine\ORM\EntityRepository $rep) {
return $rep->
createQueryBuilder('s')
->join('s.groups', 'g') // Assuming the association on your user entity is 'groups'
->where('g.name = :group')->setParameter('group','TeacherGroup');
})
)
but for datagridMapper ,it doesnt work.
$datagridMapper
->add('teacher',null,
array(
'query_builder' =>
function (\Doctrine\ORM\EntityRepository $rep) {
return $rep->
createQueryBuilder('s')
->join('s.groups', 'g') // Assuming the association on your user entity is 'groups'
->where('g.name = :group')
->setParameter('group','TeacherGroup');
}))