1

I'd like to have an EntityReference field be autopopulated by the node that was just navigated from.

So the workflow would be:

User views page for Business A -> User clicks review link -> User is presented with review form, & EntityReference field is automatically populated with the name/id of Business A.

What I don't know is which action to designate to tell Rules to do this. I have Event set to "before saving content," and Elements set to "Entity has field, Parameter: Entity: [node], Field: field_venue_reference." These seem like the correct settings for these portions from what I have read, but since I'm new to Rules, I'm not completely sure of that either. Any suggestions?

4

You want the Entity Reference Prepopulate module. It's very similar to the Node Reference URL module but the maintainer of that module is stubborn and sticking to only referencing Nodes and not Entities.

Rules has always had a hard time with prepopulating reference fields so please don't go that route. You can combine Rules and ERP by using Rules to populate other fields and ERP to handle the referencing.

Everything is URL based so you must setup your links appropriately. The structure is node/add/article?[field_ref]=[id] So you could have node/add/review?field_business_ref=457

your link to the form could look something like l('add review', 'node/add/review?field_business_ref='. $node->id)

  • Scratch that. Drupal 7 handles node references perfectly but in your case I still advise you to use to ERP. – Scott Knight May 8 '12 at 22:54
  • Perfect. That does exactly what I was looking for, and is much easier than trying to implement a solution via Rules. Thanks! – Mrweiner May 9 '12 at 0:57
  • Is there a way to display the resulting reference field as plain text instead of within a text field? Obviously the module displays as a text field to allow user input for the reference, but since it's already populated, it looks a little silly sitting inside a field. – Mrweiner May 9 '12 at 23:48
  • Yes, when you edit the field you will have the option to 'disable' or 'hide'. Disabling shows the reference but prevents the user from editing the field. Try logging in as a different user (other than admin) to see the effects. – Scott Knight May 15 '12 at 0:11
  • Sorry I wasn't clear. Yes, I see the option to disable, which I have selected right now. I mean is there a way to display as plain text not contained within a text field. So, display it as though it is just text on the page as opposed to looking like it is within a field. – Mrweiner May 15 '12 at 18:13
0

If you have 2 node types Bussines and Review, and you only want to add the reference, than Node Reference URL might be the solution for you. Here is a greate tutorial for this module

http://mustardseedmedia.com/podcast/episode37

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.