0
我有一張我希望能夠逐行編輯的數據表。最明智的做法是讓每一行都有自己的形式。我可以在Symfony2 中做到這一點,而不是鏈接的父實體? documentation只顯示如何與家長做。Symfony2 - 是否可以創建一個獨立的窗體集合?
我有一張我希望能夠逐行編輯的數據表。最明智的做法是讓每一行都有自己的形式。我可以在Symfony2 中做到這一點,而不是鏈接的父實體? documentation只顯示如何與家長做。Symfony2 - 是否可以創建一個獨立的窗體集合?
你的控制器動作:
public function gridAction($criteria) {
$entities = $this->getDoctrine()
->getManager()
->getRepository('Bundle:Entity')
->findbyCriteria($criteria);
// criteria presumably involves some gneration from routing
// and may not be a parameter at all
if (array() != $entities->toArray()) {
throw
$this->createNotFoundException('Unable to find any entities.');
}
$forms = array_map(function($element) use ($this) {
return $this->createForm(new EntityType()
, $element
, array() // form parameters here
);
});
return $this->render('Bundle:Entity:grid.html.twig'
, array(
'forms' => $forms
));
}
而且你的枝杈:
<table class="records_list dataTable" id="CaseloadTable">
<thead>
<tr>
</tr>
</thead>
<tbody>
{% for form in forms %}
<tr>
{{form_widget(form)}}
</tr>
{% endfor %}
</tbody>
</table>
然而,你可能得到更好的服務看這個: https://github.com/Abhoryo/APYDataGridBundle
您好,您不必使用'data_class'在所有你可以在數組上工作...但我不知道我是否正確...請告訴'鏈接父實體'是什麼意思? – l3l0
閱讀我上面提供的鏈接。在那裏,Task基本上是標籤的父項。在我的情況下,我只想爲每個標籤提供一個表單 –