I'm trying to display all events belonging to each organizer. If there is duplicate content for the oragnizer's name, it will only display the events belonging to the organizer with the highest id.
Organizer table
|id |name |
--------------------
|1 |organizer 1 |
|2 |organizer 1 |
Event table
|id |name |organizer_id |
-------------------------------
|1 |event 1 |1 |
|2 |event 2 |2 |
Twig
{% for organizer in organizers %}
{% for event in organizer %}
{{ event.name }}
{% endfor %}
{% endfor %}
Result
event2
Result wished
event1
event2
I've solved the problem by adding a constraint of unicity on organiser name. So the Organizer table, can't have the same organizer name twice
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.