Problem/Motivation
When you place a hierarchical select inside a field collection and, during the content creation, you try to add a second field collection, the hierarchical select inside the first one lost the entered value.
Proposed resolution
The solution is to store in the $form_state['storage'] each element before form_hierarchical_select_process returns it using an array with keys composed using all the parents of the element.
When a key is present in the storage, form_hierarchical_select_process returns directly the stored element.
I've done all teh work in the patch attached.
Remaining tasks
The attched patch needs review and test in a lot of cases to be declared stable.
Storing all the element coud be determine a lack of performance, it could be usefull to store only significant part of the element in the $form_state['storage'] structure
Original report by dandaman
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | hierarchical_select_Fix_Add_and_Remove_Field_Collections-1466516-5.patch | 2.08 KB | sabsbrain |
| hierarchical_select.module.patch | 1.53 KB | coreykck |
Comments
Comment #1
tonypaulbarkerI couldn't figure out how to apply this patch so posted for help here:
http://drupal.org/node/1556542
Comment #2
tonypaulbarkerThis patch works great for me, thanks.
Comment #3
Anonymous (not verified) commentedPatch seems to fix the issue
TimLeytens
Comment #4
akamaus commentedWorks for me too, I tested on two sites. The first one used HS in a field collection on a node creation form and on a second HS was placed on a heavily ajaxed entity creation form built using ECK. In both cases HS used for selectiong taxonomy terms.
You saved me a day, many thanks!
Comment #5
sabsbrain commentedI have created a git patch for this for the latest DEV version of the module based on the above.
Hopefully this is a little easier to apply for people.
It seems to work fine for me.
Comment #6
lcampanis commentedWorked for me too :)
Comment #7
AlexFreem commentedPatch from post #5 works great! Thank you!
Comment #8
Davidz commentedIt works for me. Thx
Comment #9
pjmuszynski commentedHi,
I'm using this patch in case of entity connect module. When I added some node by entity connect widget and got back to my basic content type's form I couldn't add any taxonomy using hierarchical select (browser freezes). Did you noticed this issue also?
thanks in advance for help.
Comment #10
pjmuszynski commentedThat's wrong place I choosed
My issue has been solved by applying patch from this topic: http://drupal.org/node/1764350#comment-7181252
Thx and sorry for confusing post...
Comment #11
dandaman commentedPatch fixed my issue. Would be great if this could be incorporated into the official release.
Comment #12
kars-t commentedSpaces behind line end.
Please don't use tabs and no comments at line end.
Please reread the coding and comment standards.
https://drupal.org/coding-standards#controlstruct
https://drupal.org/node/1354
Comment #13
kirkofalltrades commentedI applied the patch in #5 and my issue with the Taxonomy getting reset on every instance inside the field collection was fixed. However, when I remove an entry that comes before another, I am left with a combination of the HS taxonomy field content and other fields that are part of the field collection.
My example. I have a 'Colleges Attended' field collection. College is selected with HS (State > City > College Name), then I collect start and end dates using the date field. Let's say I have 2 entries that already exist.
University 1, 9/2011-12/2012 and Univeristy 2, 2/2013 - 10/2013
And I remove the first University.
I am left with University 1, 2/2013 - 10/2013. As if I am getting the HS content of the instance I deleted, and the date content from the instance I actually wanted to keep.
Hoping for a quick response on this one. I'll likely be trying to find a way around it in the mean time.
Thanks,
Kirk
Comment #14
andypostThis is a duplicate of #1349868: Issues when Hierarchecal Select is inside Field Collection