如果你有例如下面的實體和關係:如何從非關聯實體(Symfony2)創建實體表單類型?
PurchasedService * ---> 1個服務* ---> 1 ServiceCategory
你怎麼可以創建一個formType列出所有條目從ServiceCategory PurchasedServiceType內?
由於:
$builder
->add('servicecategory', 'entity', array(
'class' => 'InvoicingBundle:ServiceCategory',
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('sc')
->orderBy('sc.serviceCategoryName', 'ASC');
},
))
結果錯誤:
Neither the property "servicecategory" nor one of the methods "getServicecategory()", "isServicecategory()", "hasServicecategory()", "__get()" exist and have public access in...
我希望直接調用實體ServiceCategory?