2016-11-25 25 views
3

我從Symfony對象發送,它包含at-sign變量中的@。 對象名稱的發票,並在樹枝模板{{ dump(invoice) }}我看對象,參數與路徑:如何在at-sign @裏面使用twig對象變量

invoice[0][email protected] 

但我不知道如何得到這個[email protected]的價值,因爲有at符號@

你能幫我一個人嗎?

+0

'@'符號是在變量名嗎?或價值? – Matteo

+0

invoice [0] ['banSpojDod @ showAs'] –

+0

我必須問...爲什麼變量名中包含@ Oo – Veve

回答

1

好,謝謝。問題在於我在循環中使用它,並且一些參數不存在。我需要添加現有條件。所以我的最終代碼工作:

{% for f in invoice %} {% if attribute(f,'[email protected]') is defined %} {{ attribute(f,'[email protected]') }} {% endif %} {% endfor %}

相關問題