I have an email field that I would like to present on the node as a name that links to the email address. As such, I am trying to edit the email field template to embed the name from a text field. However, I'm having difficulty figuring out how to access the content of this text field. I've gotten as far as figuring out that twig(_context['element']['#object'])
will give me some info about the node object, but I cannot figure out how to access the field values. Am I even in the right ballpark for accessing this data?
1 Answer
This is the node object that you have found in the field template.
You can access the field values like this:
{{ element['#object'].field_field1.value }}
-
1Perfect, thanks! Do you have any good resources for this aspect of theming in D8?– MrweinerOct 23, 2016 at 21:02
{{ dump(_context['element']['#object']) }}
Note that twig debugging should be enabled in the sitewide services.yml file.