0

I have a Views fields twig template where I want to print the Views fields values manually.

For example, using: {{ fields.body.content }}

But this only works if the Views field is not excluded from the display.

Is there a way for me to print Views fields values if they are hidden (excluded from display)?

1 Answer 1

2

You shall do it like this:

{{ row._entity.field_myfield.value }}

7
  • That doesn't work for me. I tried and got a WSOD error that logged "e Exception: Object of type Drupal\Core\Field\FieldItemList cannot be printed. in Drupal\Core\Template\TwigExtension->escapeFilter() (line 465 of /PATH/web/core/lib/Drupal/Core/Template/TwigExtension.php)." Oct 16, 2018 at 15:54
  • Try to kint fields, do you see the field you wanna render?
    – user72672
    Oct 16, 2018 at 15:55
  • {{ kint(fields) }} does not output the variables for hidden Views fields. Oct 16, 2018 at 15:59
  • Are you in the default view template ?
    – user72672
    Oct 16, 2018 at 16:00
  • I'm using the fields template (views-view-fields--VIEW_NAME--page.html.twig Oct 16, 2018 at 16:02

Your Answer

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

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