Entity Reference Views are a great way to make life easier for Drupal content creators.
Normally, when people create content on your site, each field is very plain. However, Entity Reference Views allows you to provide far more information. For example, instead of just showing a list of users, your content creators can browse through a list of names, photos and personal details.
Both Views and Entity Reference are now part of the Drupal 8 core. This made using Entity Reference Views in Drupal 8 much easier.
If you're a Drupal 7 user, read this version of the tutorial.
Step #1. Create a content view
- Create a view of the content that you want content editors to choose from. In this example, I'm going to make a view by the name "List of Speakers":
- At the top of the page, click "Add" then "Entity Reference":
- Click "Add Fields":
- Set For to 'This entity_reference (override)
- Add the fields you want to have displayed and searchable.
- Click "Settings" next to "Entity Reference list".
- Search fields: Choose the field(s) 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.
- Save and continue
- Save field settings
- Click "Add content" and the data entry for your field will use the View you created.
- If you prefer a checkbox to autocomplete go to Administrator > Structure > Types > Manage > Speakers > Form-display and change the widget type.