Answer the question
In order to leave comments, you need to log in
Is it possible to use switch inside for in twig?
seemingly simple design:
{% for item in votes %}
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<img src="http://placehold.it/320x240" alt="...">
<div class="caption">
<h3>{{ item.caption }}</h3>
<p>{{ item.description }}</p>
<p><a href="{{ path('vote_view', {'id':item.id}) }}" class="btn btn-primary" role="button">Открыть</a>
{% switch item.status %}
{% case "text" %}
<span class="label label-default">Не готово</span>
{% endswitch %}
</p>
</div>
</div>
</div>
{% else %}
<p>Нет записей для отображения</p>
{% endfor %}
Unexpected tag name "switch" (expecting closing tag for the "for" tag defined near line 27)
Answer the question
In order to leave comments, you need to log in
Twig does not support the {% switch %} tag. Use if/elseif instead.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question