I have two content types: Type A and Type B. Type A has 3 fields: title, location, and zip code.

I want to get references to Type A in a field for Type B. I have tried using the Node reference and the Entity reference modules, but they allow only to get options in autocomplete when I write the title of a Type A node. I want to get a list of all the Type A nodes with the zip code entered in the field.

  • if anybody can help me then please help me friends as it is very important for me
    – eweb
    Aug 30, 2013 at 14:27

3 Answers 3


You should use tokens and autonodetitle modules.

After enabling tokens and automatic node title , go to Stucture->content types -> edit (type A) content type.
If you scroll below you will see an option Automatic title generation .
Click on 'automatic title generation' you will see an Pattern for the title and list of options containing token list
like curent user, current date, current page, node , random etc.
Click on node and find the token related to node Type A.
Like for the field location and field zip there will be token similar to this [node:field-zip],[node:field-location]
add this into pattern for title field. Now you can check the Type B autocomplete entity reference field for type A . you will find that as title is changed the entity reference field has location and zip in the title.

  • Hi friend Thanks for your help, i tried each step mention in your answer but the main problem is that it changes the title of the node. i don't want to change the title. i just want that when i take refernce of this content type then it populate titles of referenced node based on another field. like zipcode is a filed in the another content type. if i enter zipcode 92980 then there is a field for autopopulate where i need titles which have the zipcode 92980. there are many nodes with same zipcode , i want these nodes to be populate. thanks in advance for help. please help me
    – eweb
    Sep 1, 2013 at 14:49

Text or Nodereference this module may solve your issue

It simply adds a new widget and a new formatter for the text fields provided by the great text.module from the CCK project.

The widget has autocompleting on both the existing field data and any existing node titles (you may want to filter this on specific content type(s), though, which is possible.) The formatter checks if a node exists with the title that is stored to the textfield, then it is displayed as a link to that node (if that textfield's widget is limited for any content type(s), then the target node must be one of the specified content type's, though).


The main issue here is that the node reference widget has no idea of the zip code field because it hasn't been submitted into the database yet. Yes, you have typed information into it, but until the form is submitted, it's still just out there with the client.

What you will probably have to do is code up some custom AJAX/AHAH for your form to look when your user has entered information into the zip code field, then pass that to drupal and then have drupal return your node information based upon that filter (See Views) and either repopulate or initially populate a drop down list of nodes.

Lots of information on this can be found in the Drupal Form API Reference and most probably some code examples in the aptly titled Examples Module.

Side note: If these were all node references, you could also investigate the Hierarchical Select Module.

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.