Drupal7: References Dialog module

David G - DrupalSo I have created a fair amount of websites in my career that relate data. But in Drupal, thus far I’ve rarely had a case to use the Entity Reference module. Which you’d think would be a prime candidate for relating things … but hey. I finally got around to using Entity References and wanted a slick way to allow content editors a means to Update or Create related entities. I think I found a nice solution.

So a little backstory. I have related content in Drupal before but usually I use Taxonomies or the Relation module. I just never sat down and used Entity Reference.

My current project involves moving a legacy database of Presidential Documents, Locations and People into Drupal 7.

So after creating some entity references which relate a Person to: the place they were born, where they held a government office, where they died. I also relate Documents to the location in which they were created (city, state, location) and a relation to the Person who created the document. I wanted to allow my site editors a means to be creating a Document node and create a Person or Location inline (without leaving that browser page). I found the References Dialog module.

After installing References Dialog, you can configure an Entity Reference Field to make use of it. It’s important to note that an entity reference field must be using the Autocomplete widget to properly activate the references dialog. You cannot use the Autocomplete (tags style) widget — I learned that the hard way after like 30 minutes of wasted time wondering why the dialog wasn’t appearing!

So when configuring a field we can set what References Dialog options we want; these are in addition to the default Entity Reference options:

The references dialog adds options to show: Edit, Add and Search links for referenced content.

The references dialog adds options to show: Edit, Add and Search links for referenced content.

You can kind of see what this will appear as to content editor in the above image under Default Value. The module adds some AJAXified links below the textfield for the Location (in this case).

A better example is to examine a completed piece of Person content and click some of the links:

Example completed Abe Lincoln node -- with Locations already filled out.

Example completed Abe Lincoln node — with Locations already filled out.

See above we have a completed Person entry and we reference person Abe Lincoln( with Node ID 12933).

Edit Link button for References Dialog on Location field.

Edit Link button for References Dialog on Location field.

Related Entity form for state of Kentucky.

Related Entity form for state of Kentucky.

The edit button brings up the related entity in its own window to allow the content editor to modify it without leaving the main content edit page.

Lastly if you’re creating content the Search button brings up searchable UI, similiar to the default Entity Reference search functionality — but it can be extended by configuring a custom View to supply your own searchable interface for your clients!

References Dialog leaves default Entity Reference autocomplete search, or lets you Create New content.

References Dialog leaves default Entity Reference autocomplete search, or lets you Create New content.

So this adds a great deal of functionality and enhances User Experience on top of what Drupal out-of-the-box would give!

note1: Currently References Dialog is in BETA. Without patches it does not support drupal core Taxonomy Reference fields — but they are working on it. They are also working on streamlining the modules CSS to be more friendly with community developed themes.

note2: Additionally the Search feature in References Dialog can use the Entity Reference Views integration to provide a custom search form to find related content quickly and powerfully. I may use it later! haha.

Looking for quality web hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , | Posted under Drupal | RSS 2.0

Author Spotlight

David Gurba

I am a web programmer currently employed at UCSB. I have been developing web applications professionally for 8+ years now. For the last 5 years I’ve been actively developing websites primarily in PHP using Drupal. I have experience using LAMP and developing data driven websites for clients in aviation, higher education and e-commerce. If you’d like to contact me I can be reached at david.gurba@arvixe.com

Leave a Reply

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