0
我試圖顯示一個實體字段類型展開和多個設置爲true。但是,我想顯示實體的其他屬性。這與Symfony2 : accessing entity fields in Twig with an entity field type類似,但該解決方案尚未適用於我。我收到錯誤:「」的項目「代碼」不存在。訪問實體字段類型的樹枝中的其他屬性
如何訪問實體的其他屬性(本例中爲顏色)?
這是我到目前爲止有:
$builder->add('colors', 'entity', array(
'class' => 'PrismPortalCommonBundle:Color',
'property' => 'code',
'expanded' => true,
'multiple' => true,
));
,並在樹枝的模板:
{% for color in form.colors %}
<tr>
<td>{{ form_widget(color) }}</td>
<td>{{ color.vars.data.code }}</td>
</tr>
{% endfor %}
請檢查什麼{{轉儲(color.vars.data)}}返回 – Nisam 2013-05-06 06:36:30
轉儲整個'form.colors'請。看起來你有「空」的對象 – DonCallisto 2013-05-06 07:05:11