![](/img/trans.png)
[英]Symfony 4 EasyAdmin - Property does not render when overriding bundle template
[英]Symfony 4 EasyAdmin - Render association data type in twig template
在我的Symfony 4應用程序中使用EasyAdmin。
在用戶實體的顯示視圖上工作。
我想在顯示視圖中為我可以設置樣式的用戶列表顯示所有相關的(1-很多)實體。
此數據類型的默認模板為@EasyAdmin/default/field_association.html.twig
。
如何為用戶引用實體列表(預訂,評估等)。
我曾嘗試在user_show.html.twig中添加{{ entity.assessments }}
,但出現錯誤:
Object of class Doctrine\ORM\PersistentCollection could not be converted to string
如何在此樹枝模板中渲染這些相關的(關聯的)實體?
嘗試迭代您的數組集合:
<ul>
{% for item in entity.assessments %}
<li>{{ item.name }}</li>
{% endfor %}
</ul>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.