Download & Extend

Error adding new field collection with Hierarchical select inside

Project:Hierarchical Select
Version:7.x-3.x-dev
Component:Code
Category:bug report
Priority:major
Assigned:coreykck
Status:needs review

Issue Summary

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

Issues when Hierarchecal Select is inside Field Collection

AttachmentSize
hierarchical_select.module.patch1.53 KB

Comments

#1

I couldn't figure out how to apply this patch so posted for help here:

http://drupal.org/node/1556542

#2

This patch works great for me, thanks.

#3

Patch seems to fix the issue

TimLeytens

#4

Status:needs review» reviewed & tested by the community

Works 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!

#5

Version:7.x-3.0-alpha5» 7.x-3.x-dev
Status:reviewed & tested by the community» needs review

I 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.

AttachmentSize
hierarchical_select_Fix_Add_and_Remove_Field_Collections-1466516-5.patch 2.08 KB

#6

Worked for me too :)

#7

Patch from post #5 works great! Thank you!