i have a content type "actuality" with a reference to an other content type "event". In "event" i have a "field_date" which i want to print into my "actuality" node. What is the best way to do that ?

I've already created a template node--actuality.html.twig and trying to print inside node.field_event_associated.field_date but it's not working.



For any type you of field get the value directly like you wrote node.field_name.value. But for reference type you can't get the value directly. For reference type you have to write



and for uri u can write: node.field_team_location.entity.uri.value

  • Hi and thanks for your answer. I don't manage to access my values like this, the only thing i can do is : {{ content.field_evenement_associe[0]['#url'].options['entity'].field_date_event.value }} but i find it very complicated. Do i miss something ?
    – lchabrand
    Dec 12 '16 at 5:59
  • 1
    If you apply the example from this answer you get a shorter version: {{ node.field_event_associated.entity.field_date.value }}.
    – 4k4
    Dec 12 '16 at 7:59
  • Thanks i get some results with this version. By the way, where can i find this in Drupal doc ? Regards
    – lchabrand
    Dec 12 '16 at 23:48
  • You can find it in twig template documentation of drupal 8. Dec 13 '16 at 13:24
  • It will show you the first value, How will get the All value available in entity reference fields Jun 21 '19 at 14:20

If you want to render a properly formatted single field of a referenced entity you'll simply have to use the |view filter on the desired field of the referenced node.

Let's say the field_customer on my parent node references a customer content type entity that holds the customer's address in field_address.

{{ node.field_customer.entity.field_address|view }}

Use the referenced entity's display settings to define the format of the field you want to render.

Example on drupal.org


Output entity reference field value and create url on twig.

entity reference value : {{ node.field_name.entity.title.value }}

entity reference url : {{ url('entity.node.canonical', {'node': node.field_name.target_id}) }}


It's been a long time i've posted this question, but i found this post very very usefull : Getting Drupal 8 Field Values in Twig


The value you're mostly looking for would be the title value:

{{ node.field_organisation_reference.entity.title.value }}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.