Closed (duplicate)
Project:
Inline Entity Form
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
19 Aug 2012 at 20:56 UTC
Updated:
1 Jul 2013 at 21:46 UTC
Jump to comment: Most recent file
Comments
Comment #1
jherencia commentedComment #1.0
jherencia commentedSyntax problems fixed.
Comment #2
jherencia commentedUps, there were some lines of code from #1526084: Abilty to add existing entities that I've removed.
Comment #3
bojanz commentedNow that's one ugly patch :)
Why are you nesting IEFs? Doesn't that give you horrible UX? I'm tempted to just say "never do that", but I'm prepared to hear your use case.
The IEF ID is the instance id of the reference field (so different for each bundle, yes). Why does that give you a problem?
It should only be a problem if you're using IEF to manage the same entity type&bundle as the parent form (which is a whole new level of crazy :))
From a glance at the current code it seems to me that both inline_entity_form_save_row_weights and inline_entity_form_process_entity_form should work unless there's an IEF ID clash, so waiting for your explanation on that one.
Comment #4
mariusal commentedThis patch fixes issues that I have then using the IEF with the Commerce Product Bundle module. See #1751140: Integration with Commerce Product Bundle module
Comment #5
jherencia commented@bojanz
Well, let my try to explain the use case ;).
We have to provide a client the possibility of generating pages that are ordered compounds of ordered lists of nodes (more or less a compound of views giving the client the possibility to change the order of the views and the order of the items inside). For that, we've created different content types, which we called components (views rendered in different ways depending on the component type), that each of them are a compound of specific elements: Documents, Links, etc
The architecture
The design the client gave us had some special cases like pages with these components and order:
- Gallery
- Docs
- Gallery
- Links
The client found too difficult to use panelizer and/or panels (there are too many options they didn't need) and wanted to use a common form to edit and create its pages, so IEF was a perfect fit.
With this architecture the client could add multiple galleries, lists of docs, etc and be able of ordering them as they wanted and even edit any of the components and its elements in the same page. So we had the need to nest IEFs in IEFs.
About the horrible UX
I thought the same, but surprisingly the client is very happy. They find very simple, easy to use and verstaile the way to create pages that lead to so many different combinations.
IEF ID
Outside this use case, when I started analyzing the code I thought that even the use case of nesting parents inside childs was rare. The idea of using an ID with the path could be a better aproach than the instance ID. I think there could be other situations in which IDs could collapse, so changing will prevent future issues. Probably @mariusal problems are because of this.
About the IEF ID clash
It happens when I create a page and inside two different components of the same type. The ID used was repeated and the instance appeared twice but in different ief_paths.
I understand the use case could be rare because almost every installation of this module is in Commerce environments but, if it gains in popularity, this kind of use cases could be more common.
I hope I have explained it well ;).
Comment #6
akalam commentedI have the same use case
In my case (only tested in firefox), the error given is with allowed memory size exhausted, when I try to edit the nested entity, but the memory limit is about 350Mb... Is normal to consume so much memory?
Comment #7
akalam commentedI got the same error with 1000Mb of memory_limit. I got allways the error in
modules/field/field.form.inc on line 515Is maybe there some kind of recursion?
Comment #8
akalam commentedI think it could be a good replacement of book module... :)
Comment #9
jherencia commented@desarrollo2.0
I think the patch needs a reroll because HEAD has changed a lot since I developed this. I will be happy to do it but first I'd like to know if it will be committed.
Comment #10
bojanz commentedYou present a valid use case, jherencia.
I have a fix in mind, let me roll it.
Comment #11
jherencia commentedOk, great thank you :).
Comment #12
garphyDoes the fix still lives in your mind ?
Could you point us in the direction you thought about ? I would happily try to implement it as I face the same use case with the same issues.
Cheers.
Comment #13
koenc commented@garphy and @bojanz
any plans/progress on implementing the nested IEF functionality? We too are facing the issue and are considering to fix. It proves the current code isn't really aware of the nesting-level; only 1 level supported indeed.
Thanks
Koen
Comment #14
tmsimont commentedrelated: #1835852: Multiple same-entity add/edit forms on one page results in duplicate DOM Id's
working on a patch..
Comment #15
bojanz commentedWe need an inline_entity_form_get_id function that returns a fresh id every time it's called (it can have a static variable that is incremented each time).
Then, use it across the code. Should solve all of our problems.
Comment #16
tmsimont commentedin a patch I attached to the issue referenced in #14 i just used the element's parents to generate an id. It worked to solve an issue I had using IEF with commerce_registration, but i'm not sure how that would work here
Comment #17
koenc commented@bojanz et al
we're actually trying to patch ourselves now (due to an imminent deadline).
One of the things we want to be certain of, if we e.g. have a
parent, child, and grand child, to not physically write the grand child to the
database, unless we store the parent. Reason is you might end up
with orphan-grand children, if you decide not to store the parent.
With the current code that behaviour is correct, when
storing parent and child (child only is saved when parent is saved).
So just a new function inline_entity_form_get_id I do not believe will do the
entire trick. It would be nice if we could elaborate on how we'ld like to fix,
e.g. using Skype? Would any of the core developers be available?
We'll contribute our fix back to the community.
cheers
Koen
Comment #18
koenc commentedJust a quick update to whom it may concern: we're almost done with an update to the code, to support up to 3 levels of nested IEF forms (so IEF in IEF in IEF). It's hard-coded to max 3 levels; it proved too hard given the time constraints we have, to make it fully recursive.
It's not fully tested yet, and ourselves we don't use it for eCommerce, so we're uncertain how it behaves in that setup. How should we proceed, shall we just upload a patch file here?
Koen
Comment #19
dwalker51 commentedIs there any movement with a patch? Thanks.
Comment #20
tmsimont commented@dwalker51 i put up a patch here #1835852: Multiple same-entity add/edit forms on one page results in duplicate DOM Id's but it hasn't been reviewed. I'm currently using that patch on my own production site, but I'm not nesting IEF's I'm just putting multiples out on one page. It might still help you tho.
Comment #21
dwalker51 commentedThanks but I was trying out nested IEF's my use case was to have: a trip memo -> multiple trips - > each trip multiple photo albums and have the UI on a single page. I am looking at the relation module as well and just doing it individually and then relating them with say a multiple select list. Thanks again!
Comment #22
ccarigna commentedI also have a use case for supporting nested inline entity forms. @tmsimont I tried the patch that you posted in the other issue, but it didn't work. Would it be possible to get a quick update or status on this feature or plans to include it in a release?
Comment #23
tmsimont commentedsorry about that cwc -- my patch works in non-nested IEF's on one page, but seems to fail on nested IEF. I'm not sure what the status is on future development of this feature
Comment #24
pyry_p commentedGot it working in custom case, mayby this could be clue to build general solution.
Would it work by when creating entity form set child attribute and prevent processing in those trigger levels
Comment #25
dwwI also need this. ;) I'm quite new to the code of IEF, and it's too late for me to grok the internals and bojanz's proposal in #15. My use-case is potentially easier to understand than some of the one's described here.
Reviews point to an author (of the review) and point to books (being reviewed).
Books point to authors (of the book)
When creating a review node, I want to IEF the author of the review, and the book that's being reviewed. When I'm creating that book, I want to IEF another author node. My author nodes only have a few fields, so the UI really isn't bad at all (and way better than having to do it all via separate page loads/forms/etc).
Make sense? ;)
Anyway, I'll try to see if this is easy to fix when I look with fresh eyes in the morning...
Thanks,
-Derek
Comment #26
fearlsgroove commented@DWW: Have a look at the referenced issue: #1835852: Multiple same-entity add/edit forms on one page results in duplicate DOM Id's
I have a couple sites with a similar use case to what you've described and it's working well with the patch there. In fact I can't find what specific element from Bojanz's comment or what specific nested use case doesn't work with that patch applied, so this might could end up being marked as a dupe of that.
Comment #27
dwwThanks! Sadly, that doesn't seem to solve my problems, either. :/ See #1835852-26: Multiple same-entity add/edit forms on one page results in duplicate DOM Id's. But thanks for the pointer, I really appreciate it!
Cheers,
-Derek
Comment #28
jherencia commented@dww
The patch I appended does not work anymore due to the latest changes IEF has experienced.
I stopped working on this issue because @bojanz pointed that he was going to work on this, but it's been a while since that, so I'd be happy to help again. I think the best approach to not waste time would be if @bojanz explains us how this should be fixed.
Comment #29
dwwI thought he already did (in #15):
I haven't jumped into the code to see if that makes sense and how easy/hard it would be, but it seems like a pretty obvious and straight-forward thing... ;)
If this bug becomes urgent enough for my current project, I'll assign this to myself and start working on a patch. Otherwise, I'll just keep following here and am available for testing/reviewing patches.
Thanks,
-Derek
Comment #30
jherencia commentedWell, if you analyze my code you'll see it's not that easy.
There are currently two problems:
The patch in the other issue solves the ID collision and does not fix this two other problems.
If you have time and can handle this I have some environments in which I can test and help reviewing :).
Comment #31
arosboro commentedHas anyone made progress on this issue? I've create a node in a nested ief form, it saves the parent entity as many additional times as items that you added. I was able to resolve this using modified code from #24.
I tried both patches for conflicting ief ids on 1.2, but the form ids were only unique for the first two fields (parent and child). Subsequent children had the same elements as child 0 because they shared the id.
Comment #32
arosboro commentedI've patched inline entity form to support nesting up to 2 levels deep. I borrowed some ideas from jherencia's initial patch to determine the delta of the root ief widget.
Ids take the form: {parent_field_name}_{instance_id}_{delta}.
The resulting form state inline_entity_form array looks like this:
field_packages is the root widget, and has 3 items. field_tracks 0-2 correspond to each of those items, and can have as many unique items as needed.
In order to support higher levels of nesting, we need to figure out a better way to handle removing settings from form state when a parent item is removed. Currently it uses the delta of the parent being removed to determine the delta portion of the child ief_id (Which works when there is only parent > child type relationships with two fields total).
Adding a depth (0, 1, 2) to the id: {parent_field_name}_{instance_id}_{depth}_{delta} may allow for deeper nesting, but it's problematic to figure out depth when removing elements.
Please test this patch, and come back with your feedback/changes.
Comment #33
arosboro commentedOf course there was unnecessary white space. Use this patch instead.
Comment #34
arosboro commentedUpdating status.
Comment #35
bojanz commentedI have started looking into this. We need to rewrite the process function completely.
I am marking all related issues as duplicate (including this one), so that we can all focus on testing one patch.
See you in #2032649: Rework inline form submission.
Comment #35.0
bojanz commentedMinor changes.