我尝试获取一些与我所有步骤对象匹配的条目,但我在它们之间没有直接关系,因此我需要使用自定义查询。
我在我的管理课上试过:
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('texteEtape', null, array('label' => $this->getTranslator()->trans('label.step.text')));
$this->addCountryListMap($listMapper);
$listMapper
->addIdentifier('id')
->add('temperature')
->add('rincage', null, array('label' => $this->getTranslator()->trans('label.rinsing')))
->add('concentration')
->add('temps', null, array('label' => $this->getTranslator()->trans('label.time')))
->add('produit', null, array('label' => $this->getTranslator()->trans('label.product')))
->add('enabled', null, array('editable' => true))
->add('_action', 'actions', array(
'actions' => array(
'edit' => array(),
'delete' => array()
)
))
->add('updatedAt')
->add('Protocols','sonata_type_model', array('required' => true,
'class'=> 'HypredMainBundle:Protocole','property'=> 'name',
'query_builder' => $this->getProtocoles($listMapper->get('id'))));
Run Code Online (Sandbox Code Playgroud)
getProtocoles 函数:
private function getProtocoles($id) {
$querybuilder = $this->getManager()->getRepository('HypredMainBundle:Etape')->getStepProtocoles($id);
var_dump($querybuilder->getQuery()->getResult());
die();
return $querybuilder;
}
Run Code Online (Sandbox Code Playgroud)
我还想知道如何传递当前实体 id(标识符返回 FieldDescription …