Does anyone know how I can allow a user to select a venue (such as a night club or restaurant) from a node reference autocomplete field and have the address of the venue also displayed. This assumes that the venue is already in the system along with the venue's address.

The problem I am trying to solve is as follows: my website allows users to post a comment about a venue which is already in the website's database. I want the user to be able to enter the comment and type the name of the venue from an autocomplete box. I don't want the user to have to enter the address of the venue rather have it auto populate.

Any help on this would be greatly appreciated.



2 Answers 2


EDIT: Just realized that this post is a few months old. Hopefully you already found a solution to your problem. If not, maybe this can be of use.

If I'm understanding correctly, you would like to have the address appear in the published comment, and comment is a content type. I emphasize published because this method only allows the information to appear in the published node and not within the content creation form (which is unfortunate, because I've been searching for this functionality for my own site). Assuming the above is the case, then I think the best way to do this would be with Rules. These instructions should get you close, I think, but I haven't used the functionality in quite this way before. Once installed:

  • Add a field in your comment content type that matches the address/location field in your venue content type
  • Go to admin/config/workflow/rules
  • Add a new rule, and under "react on event" select "After saving new content"
  • Add condition "content is of type", and select your comment content type
  • Add action "fetch entity by id", and in the data selector input/select "node:your-reference-field:nid"
  • Add action "set a data value", in the data selector drill down to "node:address-field-of-comment-content-type", click continue, click on "switch to data selection" in the new value area if it's not already selected, and then on that data selector field drill down to "entity-fetched:address-field-of-venue-content-type"
  • Save changes

This should grab the address from the referenced node before the comment is saved, and populate the comment's address field with the referenced venue's address, after the user clicks the save content button but before it is saved. You're probably going to want to hide the address field in the comment content creation form so that users can't mess with it. It will more than likely just confuse them since they are not directly editing it. Hopefully this helps you out. Like I said before, I haven't used it in quite this way, but I have used it in a similar fashion.

You also might want to check out Entityreference Prepopulate. It allows you to fill an entity reference field automatically within the url. So, if you have a link on the venue page to create a "comment" for the venue, the you can use this module to automatically populate the entity reference field with the venue, making it so that users don't have to make the selection themselves.


If you want the address to show up on the published comment:

  • in Content Type > Comment Display
  • use Format: Rendered Node (teaser)
  • set up the Venue teaser to show the title & address

If you are already using the Venue teaser in another way, then use a Rendered View instead. First set up a view showing the Venue title and address.

  • Thanks for the answer but I don't think I was clear. I just need the user to select a venue from a list of venues. When the user selects this venue (let's say the White House) the address will also be populated as a result.
    – Paul Birgy
    Mar 6, 2012 at 3:59
  • "the address will also be populated as a result" - where will this address appear? On the comment? Or do you want it to appear on the list of selectable venues (ie, display to the user as they are doing the selection) ?
    – keva
    Mar 15, 2012 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.