0

Referencing entities is a great capability of Drupal but gives me headaches.

I have three content types: Client, Contact and Job ticket.

Clients are companies with whom I conduct business. Contacts are contact persons within these companies. The Contact content type has a reference field referencing their company's node. Job tickets are tickets for jobs these companies hire me to do for them. In this content type I have two reference fields: one for the Client and one for the Contact.

This is my problem: In the Job Ticket I have a select list field that needs to be populated with the address (or addresses, since there can be multiple values for the Address field in the Client content type) of the client when I select the client in the reference field select list. How can I do this automatically.

I tried the Field Reference module but I can't get it to work, and it would give me ALL the addresses from ALL the client nodes. I only need the one(s) from the previously selected client.

Thanks in advance.

  • 1
    Yesterday I posted a similar question and it was resolved with the Reference Field Option Limit but it doesn't work in this case. The reference field doesn't seem to pull a field within the node referenced with another reference field... headache – Carlos Tapia Nov 8 '13 at 18:51
  • Have you looked at the Hierarchical Select module? Check it out at drupal.org/project/hierarchical_select, it might do the job for you. – Jimajamma Nov 8 '13 at 20:09
  • With entityreference you should be able to create a view as your dropdown list of references. – chrisjlee Nov 8 '13 at 20:23
  • I have not checked that module @Jimajamma, I'll give it a try. Thanks. – Carlos Tapia Nov 8 '13 at 20:44
  • @chrisjlee, Will the view populate the Address field select list options dynamically? can you tell me how to configure the view? Thanks. – Carlos Tapia Nov 8 '13 at 20:46
0

You don't state much about your setup, so I am gonna presume you are using drupal 7. In that case I highly recommend using entityreferences. It replaces the former nodereference and userreference modules IMO. You can reference any entity with it. Also your custom CTs (Client, Contact, Job.)

When you create a reference field you have to option to use a 'simple' selection which indeed gives you ALL content of a certain type. But you can also choose to use a custom made view for the selection.

Using a contextual filter (which you can pass along in the entityreference field settings) you can filter the view down to exactly what you want. It's brilliant, try it!

  • This was a problem I had over four years ago which I resolved by doing some "artisanal" tweaks to Drupal. I later found the Entity Reference module which would have been the perfect solution to my conundrum. I'm selecting your answer as the correct one because it is. Thanks! – Carlos Tapia Feb 23 '18 at 19:35
  • Artisinal gheheheh, nice one. Thanks for the approval BTW – firfin Feb 24 '18 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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