I guess this is pretty easy but I am a novice at Symfony so I got troubles with it.
So basiccaly here is what I got in Controller
public function pollResultsAction( $pollId ) {
$poll = $this->get('doctrine')->getRepository('Myproject:Poll')->find( $pollId );
$questions = $poll->getItems();
return array(
'questions' => $poll->getItems()
);
}
where $questions is a Collection of questions of the Poll given
then I have
{% if questions %}
<ul>
{% for question in questions %}
<li> {{ question.question }}</li>
// here I'd like to have answers to given question
{% endfor %}
</ul>
in a Twig file.
I can get to answers like this
$answer = $onequestion->getAnswers();
I'd like to print answers to each question in twig. I think I need to some foreach loop in controller but I don't know how to return it to twig.
Thank you for your help in advance.