16
我正在使用symfony2並且具有一種表單來保存一個用戶與某些規則的關係。這些規則由公司的管理員用戶設置。在這種形式中,在我選擇用戶進行更新後,我必須選擇該用戶有權限的最終規則。Symfony 2創建一個具有2個屬性的實體表單字段
問題是,我可能有更多的一個規則具有相同的名稱(這是另一個實體),但值是不同的。所以,當我建立的選擇框,我必須表明的名字和喜歡的價值:項目
- 數量 - 10
- 數量的項目 - 該項目的20
- 的價值 - 200
- 價值項目 - 500
但現在我只可以顯示沒有 「 - $值」 使用波紋管代碼:
$form = $this->createFormBuilder()->add('myinput', 'entity', array(
'class' => 'myBundle:Rule',
'property' => 'childEntity.name',
'label' => 'Filas Permitidas',
'expanded' => false,
'multiple' => true,
'choices' => $this->getDoctrine()
->getRepository('MyBundle:Rule')
->findAll(),
'required' => true,
))->getForm();
因此,作爲財產我想得到$myEntity->getChildEntity()->getName()
和$myEntity->getValue()
。
有沒有辦法做到這一點?
完美!謝謝! – PedroHCan
現貨!恭喜.. – medina