0

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

0

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 '17 at 7:38
  • 1
    you can add a comma with the condition that it is not the last item: {{ not loop.last ? ', ' }} – 4k4 Jul 14 '17 at 8:06
  • By the way, how can I output also the URI/URL? – user77193 Jul 26 '17 at 6:51
  • I don't know which URI/URL you mean, but don't explain here, ask a new question. – 4k4 Jul 26 '17 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy