I'm trying in my code to build a list of courses in an html file (using twig) - but the thing is - I need to use it twice. Once to get the list (and that obviously worked), and once to create a form with multiple checkboxes running in another for loop. I read that the 'unset' function can fix this problem - but it says in doesn't exist in Twig. here's my code:
{% for course in courses %}
<a href="/course/{{course.id}}">
<div id="info-box">
<img src="/views/{{course.image_link}}" alt="" width=95>
<p style="margin-left: 1rem;">{{course.name}}</p>
</div>
</a>
{% endfor %}
and then I need to write a form:
<form>
{% for course in courses %}
<input type="checkbox" name="course" value={{course.id}}>{{course.name}}
{% endfor %}
</form>
The second loop doesn't work. I'd love for some help please! :)
and the courses
variable comes from a different index file that sends it to an html file.