We're using the Field Collection module to enable us to have groups of data that you can add more than one of to a node. However, the Hierarchical Select module doesn't seem to be compatible.
After adding a Hierarchical Select within a Field Collection, on the node creation screen the AJAX of the first select works pretty well, although there's a bunch of "You need to fill in this field" messages even though you really haven't even seen those fields yet. But the main problem is when you add another entry to the Field Collection, all of the Hierarchical Select values within that Field Collection are emptied out.
It seems to me that there's something within the code of Hierarchical Select that don't really take well to the form being rebuilt again before submission, is that correct? Is there anything that can be done to resolve this? I'm somewhat familiar with the D6 CCK system so with some hints as to where changes need to be made I may be able to tinker around and get things working. Thanks!
Comments
Comment #1
dandaman commentedUpdated title for clarity.
Comment #2
dandaman commentedIt seem that, when you click the button to "Add another" field collection, it does send the data filled out by the Field Collection including the Hierarchical Select data, but the
form_hierarchical_select_process()function is never executed. Thus, the Hierarchical Select fields are empty instead of displaying the data already entered. (I may be wrong about this; I'm just trying to figure out the issue myself.)Comment #3
apmsooner commentedI concur. Same problem.
Comment #4
dandaman commentedThis is definitely still a shortcoming that these two modules don't really work together. For now, I have created my own custom solution for getting around this. In other words, I created two separate fields for the hierarchical levels and added form validation and JavaScript to get it to do what Hierarchical Select used to do. So, personally, I have a custom solution for my basic use case, but this would be great to fix for other users in the long term.
Comment #5
filsterjisah commentedI also have this problem. I will also try a custom solution.
Comment #6
dmitry.n commentedI've rewritten the _hs_process_determine_hsid function to make it work until it is fixed by the maintainers:
The issue with HS is that $hsid is calculated incorrectly when inside a field collection, so I'm using the field-collection's delta for a hsid
Comment #7
ironbuilt commentedTried to implement your change and I don't notice a differenct. Are you just updating the function in the hierarchical_select.module file?
Comment #8
dmitry.n commentedyes, I've updated it. Have you tried to debug it? Did it go into
condition?
Comment #9
di3gopa commentedI also tried it, and debug it,
$element['#parents'][2]; has a value, and it is getting inside the condition, but still erasing all of the hierarchical select fields when saving, here is my example -> http://www.youtube.com/watch?v=b5aKhVK9WmY
The bug is still happening
Thanks!
Comment #10
giupenni commentedSame problem.
I have this problem also if I use Field Group Multiple instead Field Collection.
Comment #11
giupenni commented@dmitry.n :
I added your code but D7 put this error:
Comment #12
tonypaulbarkerThis patch worked great for me. You may need to wikipedia diff to understand the syntax, I applied it manually.
http://drupal.org/node/1466516
Comment #13
alexander_danilenko commentedYep, it works fine (:
"git patch" and "patch" are not worked for me. i have added manually code. and it start works (:
in attachment module (7.x-3.0-alpha5) what works fine if replace it (:
Comment #14
allabakash.g commentedThanks, It resolved that issue.
Now we are facing another issue when I am trying to remove a field collection item from the node edit form, it is removing the field collection item and it shifts removed FC item's hierarchical select field values to succeeding field collection items.
Please check the attached screenshot images.
Example:
FC : Field Collection
FXX : Field's in field collection.
HS : Hierarchical Select
Lets say i have removed Field Collection1(FC1), see the changed structure below
Comment #15
senthil.na commentedThis issue is resolved by adding below condition to the code drupal_array_set_nested_value($form_state['input'], $element['#array_parents'], array()) in form_hierarchical_select_process function.
Thanks
Comment #16
allabakash.g commentedThanks devasena,
it was helpful!
Comment #17
senthil.na commentedI'm attaching updated patch file for hierarchical_select.module.
Comment #18
mavimo commentedRerolled patch to 7.x-3.x-dev
Comment #19
wim leersThis is not even close to RTBC, sorry.
This cannot be RTBC if there's still a @todo
Punctuation!
s/$elhsid/$hsid/
Comment #20
andypostClosed as duplicate #1466516: Error adding new field collection with Hierarchical select inside because the patches are the same
Comment #21
antonnaviHere is my implementation of this issue fix (patch is bit modified combination of existing patches).
Comment #22
andypostPlease re-roll to address minor nitpick, otherwise RTBC
trailing white spaces
Comment #23
antonnaviTrailing white spaces was removed
Comment #24
andypostFinnaly this works!
Comment #25
antonnaviFixed path to module on patch.
Comment #26
andypostDarn, path in the patch
Comment #27
kirkofalltrades commentedPatch in #25 seems to do the trick for me. My only remaining request would be that the HS field is reset (like other fields are) when you remove the last remaining item in a field collection.
Thanks!
Kirk
Comment #28
glajman commentedI have the same problem but using version alpha6.
Does anyone know if this can be patched for alpha6 too ?
Regards
-G
Comment #29
GBain22 commentedNot working for me either - HS will not show the next dropdown after I choose a value - no errors thrown in the console - tried #25 but no difference
Comment #30
glajman commentedI am now using alpha5 but could not patch this correctly. Getting malformed patch error. Any help?
Comment #31
badalsolanki commented#21 works fine...thanks
Comment #32
jon pughRe-rolled on dev snapshot.
I'm not sure this fixes it. I am still having problems, but my site has lots of those... ;)
Comment #33
jon pughComment #35
stefan.r commentedCommitted, thanks!
Comment #36
stefan.r commented