In my symfony project, I pass from the Controller a variable called 'button'.
In this case 'button' has the value 'content' but this is not always.
I need it to display the content of phrase.content in the '.html.twig' file but I can't.
index.html.twig:
button = 'content'
{% for frase in frases %}
<tr>
<th scope="row">{{ frase.id }}</th>
<td>{{ frase. ~ button }}</td>
</tr>
{% endfor %}
I have tried like this but it gives me the following error:
Expected name or number. (500 Internal Server Error)
----EDIT----
If I put frase.content directly it does, but if I put frase[button], it gives an error
Impossible to access a key" content"on an object of class" App \ Entity \ Frase"
that does not implement ArrayAccess interface.
frase[button]. done.