0

I have a field_intervenantfield which contains a user entity reference. In the commerce-product template file, I want to access the description field of each intervenant.

How can I achieve it?

I tried reading the following values, but none of them returns what I am looking for.

  • product.field_intervenants.entity.field_description
  • product.field_intervenants.0.entity.field_description
  • product_entity.field_intervenants.0.entity.field_description
  • product_entity.field_intervenants.field_description
  • product_entity.field_intervenants.field_description.value

Do I need to loop through it, or am I missing something else?

0

You should definitely use a loop, as the referenced entity fields returns an array, you can see an example here and adjust it by you own needs https://stackoverflow.com/questions/58291698/drupal-8-twig-entity-reference-sub-fields-templating

New contributor
Lilian Catanoi is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

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.