How to Use Entity Reference Views in Drupal 7
Entity Reference Views are one way you can make life easier for Drupal content creators.
Normally, when people are creating content on your site, each field consists of a single box with a single data point. For example, in a list of people, you might get only the person’s name.
Entity Reference Views allows you to provide far more information. For example, you can add photos and personal details to your list of people.
Entity Reference Views in Drupal 7
In this example, I have a content type called “Presentations” and another content type called “Speakers”. Every time I add a presentation, I want to choose from a list of speakers.
- Install and enable Views and Entity Reference.
- Go to Structure > Views > Add new view.
- Create a view of the content that you want content editors to choose from. In this example, I’m going to make a list of “Speakers”:
- At the top of the page, click “Add” then “Entity Reference”:
- Click “Settings” next to “Entity Reference list”.
- Search fields: Choose the field you want users to search by.
- Click “Apply (this display)”.
- Check the preview to make sure your view is working …
Step #2. Add a Field with the Entity Reference View
- Go to Structure > Content types.
- Add an “Entity Reference” field.
- Target type: Choose to link to nodes, users, files or whatever else you want to display.
- Mode: Choose “View: Filter by an entity reference view.”
- View used to select the entities: choose the view you created.
- Click “Save field settings”.
- Click “Add content” and the data entry for your field will use the View you created:
Entity Reference Views Widget
It’s possible to extend this module by using Entity Reference View Widget. This places your view inside a pop-up box to make it easier to select items.
There’s a tutorial here and this video has guidance:
Entity Reference Views in Drupal 8
Both Views and Entity Reference are now part of the Drupal 8 core. To use Entity Reference Views in Drupal 8, the process is like this:
- Create a view, as we showed above.
- Go to Structure > Content types > Add field.
Click through the settings and under “Reference type”, you can choose “Views: Filter by an entity reference view”.
Please note this is currently broken in 8.0+ [url=https://www.drupal.org/node/2174633]https://www.drupal.org/node…[/url]
Thanks for sharing.
kudos, this helped a lot.
What’s the specific article you’re referring to?
The link point to a list of articles, but I’m looking for information on how to achieve this in Drupal 8 (if possible, again…).
Thanks for the article, Steve. I’m having a problem getting 2 field values (category and subcategory (title)) to appear in the drop-down list in my Software Documentation content type. Only the subcategory appears. This is a problem because the same subcategory name can appear under more than one category. In your example, your ER field has 2 fields. So what am I missing? I’m using Drupal 8. As I finished typing this, I see another comment saying “this is broken in Drupal 8.0+”. Could that be why it’s not working for me?
Is this still not possible in Drupal 8?
I can create a page view with a formatted table, which also shows grouped sections of content.
But how can I use this ‘grouped list’ as the contents of a field on a content form?