Print Webform reference in custom view display On our D8 site we have a content type with a webform reference field field_reference_webform.
We then created a view with a custom views display style plugin for above content type that uses the webform reference field field_reference_webform.

What we want to achieve is to print the webform field in our custom view display style directly via views-view-our-display-plugin.html.twig.

The contents of our Webform reference field, however, wouldn't print. We tried to print it with below code:

{% if rows|length %}
{% for row in rows %}
{{ row._entity.field_reference_webform }}
{% endfor %}
{% endif %}


Instead we get the following error:

Object of type Drupal\webform\Plugin\Field\FieldType\WebformEntityReferenceFieldItemList cannot be printed


We cannot figure out what we got wrong.

We are on Drupal 8.6.2 using Webform 8.x-5.0-rc22
At first glance it would seem you need to render this webform yourself in a preprocess function and then pass it to twig. You are trying to access the entity object using row._entity.field_reference_webform which is protected from outside access. However views should already be rendering this webform. I think maybe your template file is just setup wrong. All you have done is create a view, and put a template file for it in your theme correct?

For row level output, if your display is setup as unformatted list, your views twig file should be named:

views-view-unformatted--our-display-plugin.html.twig


and the basic code inside it should be:

{% if title %}
  &lt;h3&gt;{{ title }}&lt;/h3&gt;
{% endif %}
{% for row in rows %}
  {%
    set row_classes = [
      default_row_class ? 'views-row',
    ]
  %}
  &lt;div{{ row.attributes.addClass(row_classes) }}&gt;
    {{- row.content -}}
  &lt;/div&gt;
{% endfor %}


Just use {{ row.content }} which should have the rendered webform in it already.

If that doesn't work perhaps we need more information on what exactly youre trying to create a template file for. The view container, the row level, or the field level.