Here is the example:
Parent Content Type: Author
- field1: Name
- field2: Age
- field3: Picture
- field4: Entity Reference to Books
Child Content Type: Books
- field1: Title
- field2: Description
- field3:Entity Reference to Author using prepopulate (need help)
Author has entity reference to Books using Inline Entity Form. So when creating an "Author", we can add "Books" they have written inline.
When a user visits an individual "Book" page, I want a field that links back to the "Author" who wrote it. How can I create this link automatically when creating a "Book" entity inside an "Author" entity (using Inline Entity Form)?
I assume I have to create a Book field3 that is an Entity Reference to Author that uses prepopulate. But I have not been able to configure this correctly to get it working as wanted. Any ideas?
Comments
Comment #1
dtrees commentedI had a similar problem and I'm guessing other people will have same issue. Its possible to do this via rules without entity reference prepopulate see below. Note in the rule example below you'll have to create the component before you create the rule.
Rule upon save of Author content type:
Condition:
Content is of type
Parameter: Content: [node], Content types: Author
Action: Rule component (execute rule component)
rule: Populate entity reference for book (The rule condition created below, this passed the node id of the Author Page saved and the value of the entity reference to books field on the Author page to a component a that you create)
Parameter: Book parameter: [node:Entity Reference to Books], Author Parameter: [node]
Step 1: Create a rule component labeled here as Populate entity reference for book
Create two variables in the component with the node data type: Book Parameter and Author Parameter
Conditions:
(Check the Book Parameter for the following conditions:)
AND
Content is of type
Parameter: Content: [book-parameter], Content types: Book
Entity has field
Parameter: Entity: [book-parameter], Field: entity_reference_to_author
Data value is empty
Parameter: Data to check: [book-parameter:entity_reference_to_author]
Actions: (if that all checks out the set the data value of the entity reference author field to the Author parameter
Set a data value
Parameter: Data: [book-parameter:field:entity_reference_to_author], Value: [Author-parameter]
Comment #2
hoff331 commented@dtrees
I have been at this all day and still cannot get this to work. Can you contact me via my Drupal.org account or at hoff331 @ gmail.com?
Comment #3
drupalok commentedi don't know if this helps you but have you tried corresponding entity references module?
http://drupal.org/project/cer
Comment #3.0
drupalok commentedtypos