Closed (fixed)
Project:
Inline Entity Form
Version:
7.x-1.0
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
17 Jan 2013 at 18:54 UTC
Updated:
31 May 2013 at 10:10 UTC
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
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, how can I create a field that links back to the "Author" who wrote it?
I assume I have to create a Book field3 that is an Entity Reference to Author. But how do I make that reference automatic?
Comments
Comment #1
bojanz commentedYou can't make it automatic.
You add an entityreference field to the child, then implement hook_entity_insert to set the field on the child when the parent entity is first created.
Comment #2
hoff331 commented@bojanz
I have changed the code to reflect my nodes and field names, however, it is still not working. To better understand my use case, a user creates an "Auction" node. Within the "Auction" parent node, the user can add "IFS" (Items For Sale) child nodes using IEF.
Parent Node = "Auction"
- IEF field called "field_IFS_add"
- user can create multiple "IFS" using IEF
Child Node = "IFS" (Items For Sale)
- entity reference field called "field_ifs_reference"
However, I receive the following Error:
Comment #3
bojanz commentedWell, the error means it can't find field_IFS_add on your auction node. Maybe it's field_ifs_add? Case matters
Comment #4
hoff331 commented@bojanz
You were correct (IFS should have been "ifs"). However, the module does not perform as anticipated.
Now, if you add child nodes and click "save" on the parent node, the node/add form refreshes and clears all user input. The parent node is not saved.
The child nodes, however, are saved and available in the content. The child nodes do not contain references to the parent node (how could they, the parent node does not exist).
Comment #5
EmanueleQuinto commentedJust to refer to a previous discussion that solved my issue related to backreferences similar to the Chris's one.
Sometimes you need a back reference because you need to expose some content from the back reference. As pointed out by Damien in the referenced issue (oh references again) you can use EVA as well.
It works, it's stable and fit the needs for complex visualization of data. It does the job.
Comment #6
bojanz commentedNothing more to be done here.