Module Monday: Entity Reference

Module Monday: Entity Reference

In Drupal 5 and 6, the “Node Reference” and “User Reference” fields allowed site builders to connect different content types to each other and connect nodes to arbitrary users. They were great for building out complex data structures, and in Drupal 7 the two modules live on as a separate project. However, Drupal 7 also heralds the arrival of the entity system, a unifying API for all sorts of Drupal objects like Users, Nodes, Comments, Files, Products, Blocks, and so on. What about creating fields that link to all of those entities? That’s where the new Entity Reference module comes in.
Screenshot of selecting an Entity Reference field
Like the Node and User reference fields we’re familiar with, Entity Reference fields can be placed on any “fieldable” item in Drupal 7. You must configure what kind of entity you want the field to point to — unfortunately, it doesn’t support fields that can point to many entity types simultaneously. However, it makes up for it by supplying a “multiple-item autocomplete” input widget that can be used across any entity reference field. Like the Taxonomy tags field widget that comes with Drupal core, it allows you to use auto-complete text entry to choose items, and use commas to separate multiple items.

Leave a Reply

Your email address will not be published. Required fields are marked *