I'm trying to figure how I can get all the values inside an entity reference field

As shown in this image, I have an entity field called Target Participants(field_program_participants) with multiple values. enter image description here

I have tried to output the values using node.field_program_participants.entity.label, but it only outputs one value.

enter image description here

How can I output all the values inside the field

1 Answer 1


You have to loop over the field items:

{% for item in node.field_reference %}
  {{ item.entity.label }}
{% endfor %}
  • Hey thanks for this, sorry for my ignorance didn't know that I had to do a loop in order to obtain the values. By the way is there a way I can add comma if there is two or more values?
    – user77193
    Jul 14, 2017 at 7:38
  • 1
    you can add a comma with the condition that it is not the last item: {{ not loop.last ? ', ' }}
    – 4uk4
    Jul 14, 2017 at 8:06
  • By the way, how can I output also the URI/URL?
    – user77193
    Jul 26, 2017 at 6:51
  • I don't know which URI/URL you mean, but don't explain here, ask a new question.
    – 4uk4
    Jul 26, 2017 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.