View Entity Reference Field Formatter

This project is not covered by Drupal’s security advisory policy.

View Entity Reference Field Formatter

This (small) Module allows you to use a view to display an entity or entities for an entity_reference field display.

core ships right now with the entity_reference field formatters
Entity ID
RSS category
Label
and ...
Rendered entity
"Rendered entity" is cool because we can use display modes as settings...
however this is not 100% exactly what we need some times and would't it be cool to be able to use the views module to display the referenced entities ... this module does just that.

This will work with any referenced entity type that is supported by views !!!

you need a view with a CONTEXTUAL FILTER of the ENTITY ID that the field has referenced

A How TO Example

Lets say you have a Standard Drupal 8 install with Article, this content type ships with the field "field_tags"
which is an entity reference field. which references the vocabulary tags.

Enable this module...
then goto (content types > article -> manage display mode )
"admin/structure/types/manage/article/display" and see
for field Tags change the formatter to "Views render entity ref field formatter"
click the settings cog

enter the machine name of the view (the view_id) you want to use and the display (or just use default)
and save.

example settings

Example view configuration
admin/structure/views/add

crate new view of with settings Show (Taxonomy Terms) of type Tags and save ...

(I called mine Article Tags Display)
at this point you can look at the url to get the View Id to use in the field formatter settings.
example /admin/structure/views/view/article_tags_display

note by default its showing all the terms on the site, we don't want that so goto

ADVANCED -> CONTEXTUAL FILTERS -> add
select "Term ID" or if not using taxonomy term use the corresponding (entity id) field..
WHEN THE FILTER VALUE IS NOT AVAILABLE
select Provide default value,
and for Type select Fixed value
and for Fixed value enter "0" (Zero)
go down to MORE and select "Allow multiple values"

after that and you have entered the view id in to the field formatter you are good to go.

example settings

example settings

example settings

After all that edit your view to be exactly what you want.

Supporting organizations: 
Sponsor Development

Project information

Releases