如何检索数组元素的值(字符串)并检索实体的属性值?我试过这个:
{% for item in items %} //item is an entity
{% for column in columns %} //column is just an array with name of columns
{% set columna = column.value %}
{{ item.columna }}
{% endfor %}
{% endfor %}
答案 0 :(得分:1)
如果要动态访问对象的属性,可以使用attribute function:
{% for item in items %}
{% for column in columns %}
{{ attribute(item , column.value) }}
{% endfor %}
{% endfor %}
答案 1 :(得分:0)
试试这个:
{% for item in items %} //item is an entity
{% for column in columns %} //column is just an array with name of columns
{% set columna = column.value %}
{{ attribute(item, columna) }}
{% endfor %}
{% endfor %}
我建议您阅读documentation。