G
G
Good Samaritan2019-09-19 22:23:30
Twig
Good Samaritan, 2019-09-19 22:23:30

How to access an array in a twig template through a variable set in twig?

Good evening . The controller has

foreach($data['polls'] as $poll){
                $data["count"][$i]=$this->model_poll_poll->getCount($i);
                $i++;
            }

In the template itself, in a loop, I try to do this
{% set j = 0 %}
{% for poll in polls %}
    <input type="radio" name="poll" value="{{ poll }}"  />&nbsp;{{ poll }}  {{count}}.{{j}} <br />
    {% set j = j + 1 %}
{% endfor %}

But doesn't work. How can I get data from the controller in such a loop?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question