Skip to content

Instantly share code, notes, and snippets.

@jasonglisson
Last active September 14, 2017 12:39
Show Gist options
  • Save jasonglisson/4fb8882867dc49884bab to your computer and use it in GitHub Desktop.
Save jasonglisson/4fb8882867dc49884bab to your computer and use it in GitHub Desktop.
Drupal 7 - Directions for Entity Reference Field for Views
What you could do is create an entity reference list from a view and populate your widget with the view.
Create a new view Untick Create a block and Create a page Then click continue and edit. That should get you to the master view.
Click Add to add a new display and choose entity reference. Give your display a easily recognisable name. Add your fields/ filters etc and order them as required. I usually change the items to display under pager to display all items, but I'm not sure how required this is.
Under the Format heading beside Format, click settings and set your field(s) that are to be searched when auto-completing. Under the Format heading beside Show, click settings and set your fields to be inline. Save your view.
Now head over to edit your entity reference field. Assuming you already have your field pretty much set up the only bit you might need to change is under: Entity selection mode Choose: "Views: Filter by an entity reference view" Assuming your field reference target type and view list match up you should get a dropdown appearing under "View used to select the entities" with your newly created view listed in there. Choose it and save.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment