Код: Выделить всё
$builder->add('parent', 'entity', array(
'class' => 'KprCentarZdravljaBundle:Category',
'query_builder' => function($repository) use ($param, $catID) {
return $repository->createQueryBuilder('p')
->where('p.id != :id AND p.parent = :parent')
->setParameters(array('id' => $param, 'parent' => $catID));},
'property' => 'name',
'required' => false,
'attr' => array('data-placeholder' => '--Izaberite Opciju--'),
));
Я создал CategoryRepository с рекурсивной функцией, которая возвращает всех детей:
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/16441771/how-to-use-repository-custom-functions-in-a-formtype[/url]
Мобильная версия