Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Simple patch to get hierarchical_select fields to work as a controlling field.
Havent testet it much, but works for me.
Comment | File | Size | Author |
---|---|---|---|
#37 | conditional_fields.module.txt | 59.02 KB | drupalnesia |
#36 | conditional_fields.js_.txt | 5.26 KB | drupalnesia |
#36 | conditional_fields.module.txt | 59.02 KB | drupalnesia |
#32 | 601416-hs-compatibility.patch | 7.04 KB | Aron Novak |
#28 | conditional_fields_h_select.patch | 6.01 KB | mirzu |
Comments
Comment #1
design.er CreditAttribution: design.er commentedThank you for this patch.
I've patched Conditional Fields 6.x-1.0-beta2 and use Hierarchical Select 6.x-3.x-dev (from 2009-Oct-02) with Content Taxonomy 6.x-1.0-rc2 on Drupal 6.14.
My approach is the following - that you better understand if I tested your patch correctly:
The user should be able to choose his/her relationship status like on facebook.
I've created a taxonomy vocabulary "relationship status" with following terms and nestings:
1. I'm single
2. I'm taken
- Is your partner registered on mysite.com? (Hierarchical Select label)
- yes
- no
3. I'm engaged
- Is your partner registered on mysite.com? (Hierarchical Select label)
- yes
- no
4. I'm married
- Is your partner registered on mysite.com? (Hierarchical Select label)
- yes
- no
Every term "yes" and "no" is the same term but only assigned to multiple parent terms (taken, engaged, married) - I hope this is not a problem in this case/for this patch.
I use Content Taxonomy (as CCK field) for this approach - Hierarchical Select works awesome with that and I hope this is not a problem in this case.
If user has chosen "yes" then a CCK userreference field shoud appear.
If users has chosen "no" then a CCK text field should appear.
My problem is that I can't see the Content Taxonomy Hierarchical Select field as Conditional field for the userreference and text field.
Sorry for this long post but I hope to explain every clear enough to help you with correct testing.
Kind regards,
Stefan
Comment #2
design.er CreditAttribution: design.er commentedI think this is the correct status.
Comment #3
design.er CreditAttribution: design.er commentedHello, any news? It would be great to get this functionality to work.
Comment #4
Bilmar CreditAttribution: Bilmar commentedsubscribing
Comment #5
peterpoe CreditAttribution: peterpoe commentedPlease hold on while #648934: Plugin system for compatibility with non-core CCK modules is developed.
Comment #6
design.er CreditAttribution: design.er commentedThanks a lot for your reply. I'll check the mentioned thread to stay updated.
Your idea with the plugin system sounds clever. I think this is the right way.
Comment #7
Bilmar CreditAttribution: Bilmar commentedThis patch seems to not work at the moment. Could someone kindly update it to work with the current dev?
I am needing to use the hierarchical select dropbox and have the selections control other fields.
I understand that further development should wait for #648934: Plugin system for compatibility with non-core CCK modules but it seems there has not been an update for two months and so until it is developed it would be awesome if the community has a way to utilize this great module =)
Compatibility with Content Taxonomy patch works and can be found at #250748: Integrate with Content Taxonomy
Comment #8
olemsa CreditAttribution: olemsa commentedMade a patch to conditional fields 6.x-2.x-dev
Seems to work fine with hierarchical_select 6.x-3.x-dev
Comment #9
Bilmar CreditAttribution: Bilmar commentedThank you for the patch. For testing I enabled hierarchical select dropbox feature and each choice is controlling a different field. What seems to happen is only the field controlled by the choice currently in the select list is showing. Adding choices into the hierarchical select dropbox doesn't have any effect on the controlled fields.
Steps to replicate:
1) field has choices A, B, C and set to hierarchical select dropbox (unlimited choices allowed)
2) on node form, having selection on choice A shows field controlled by choice A on the page
3) change selection to choice B shows field controlled by choice B (field controlled by field A disappears)
4) add choice B to the dropbox, and change select back to choice A. field controlled by choice B no longer shows and field controlled by choice A shows.
How I think conditional fields should work with dropbox feature.
1) select choice A, B or C => no fields controlled by A B or C should show yet on the page
2) add choice A to dropbox => after adding to the dropbox, fields controlled by choice A should show
Is it possible to correct this? Please let me know if more information is needed.
Thanks!
Comment #10
olemsa CreditAttribution: olemsa commentedThe patch I made works fine for me, but I'm not using dropbox. The code needed to get CF to work with dropbox (as I see it) is more than a minor fix.
http://drupal.org/node/648934 <- I hope this plugin system is coming soon
Comment #11
Bilmar CreditAttribution: Bilmar commentedThanks olemsa-
Yes, I hope the plugin system #648934: Plugin system for compatibility with non-core CCK modules will develop soon with the help of the community. The patch seems to work when using regular HS to select one term, but does not work with dropbox when multiple terms are selected (it does not recognize items in the dropbox and acts to any term that is currently highlighted (in or out of dropbox)). It would be awesome if someone in the community can help with implementing conditional fields with HS dropbox.
Thank you very much in advance.
Comment #12
peterpoe CreditAttribution: peterpoe commentedI just committed a patch that makes Hierarchical select work as controlling field. Compatibility with the dropbox is partial: only items selected in the list are handled by conditional_fields.js, so when you add them to the box, cf can't do anything about it.
Comment #13
Bilmar CreditAttribution: Bilmar commentedThanks peterpoe!
Should this post be changed to a feature request with name "compatibility with hierarchical select dropbox"? or should I create a new feature request in the CF queue?
Is there any other way of allowing a user to select 5 terms from a list of say 50 terms and have the controlled fields of the 5 terms show, but presenting the 50 controller terms in a clean way? 50 checkboxes for the controller fields seems to take too much space at the top of the node form.
Thank you
Comment #14
YK85 CreditAttribution: YK85 commentedI confirmed that HS dropbox is still not supported. Asking maintainer of HS for support.
Would anyone else be able to help out?
Thanks
Comment #15
Wim LeersDoes Conditional Fields work purely with JS (client side), purely through FAPI (server side), or a combination of both?
For JS; this is the HTML generated for a HS with a dropbox (from http://wimleers.com/demo/hierarchical-select/taxonomy):
The lineages in the dropbox are stored as hidden form input and the values are serialized PHP arrays:
On the server, you can find these arrays at
$element['#value']['dropbox']['hidden']['lineages_selections']
Comment #16
peterpoe CreditAttribution: peterpoe commentedConditional Fields uses Forms api to generate the js settings, handle required fields and handle cases where the controlling field is not in the form. Js is used to show/hide the controlled fields depending on the value of the controlling fields. Since the drop box uses ahah, it would be quite complicated to make CF work fully with it.
Comment #17
robby.smith CreditAttribution: robby.smith commented+1 subscribing
Comment #18
Wim LeersOkay, so Conditional Fields is unable to work with any complex AHAH-powered form element then?
Sounds stupid from an end user perspective, but sounds fair from a developer perspective. Forms API just isn't designed for these very advanced use cases …
I'm not sure if the amount of work will justify the gain in functionality? Maybe if some company steps up to sponsor it, but I know that I won't have time for it :(
Comment #19
theshanergy CreditAttribution: theshanergy commentedsubscribing
Comment #20
peterpoe CreditAttribution: peterpoe commentedI'm marking this as fixed, since compatibility with the dropbox is beyond the possibilities of the module at the moment. The rule to keep the module manageable since now has been not to include any module-specific code, but always try to keep it as general as possible. Compatibility with Content Profile and Content Taxonomy was obtained without breaking this rule, but I'm afraid it won't be possible with the dropbox.
Once #648934: Plugin system for compatibility with non-core CCK modules is in place (I'm working on it this moment) we could open another issue to add it as a plugin.
Comment #21
phantomvish CreditAttribution: phantomvish commentedSorry, it was the wrong thread, and I couldn't delete the posted comment.
Comment #22
Balbo CreditAttribution: Balbo commentedDo you thing is it possible to modify this patch to get hierarchical_select fields works as a CONTROLLED field?
Or should we wait for next release of the module?
Comment #23
phantomvish CreditAttribution: phantomvish commented+1 subscribing for HS as CONTROLLED field.
Comment #24
no2x CreditAttribution: no2x commentedHi there,
i tested now conditional fields (both, 6.x-2.x-dev and 6.x-2.0-beta1) together with Hierarchical Select (6.x-3.1) and Content Taxonomy (6.x-1.0-rc2) and it does not work properly for me.
I have the following setting:
Content typ: accessories:
- content taxonomy field "category" using hierarchical select. The taxonomy tree looks like this:
- field "laser printer information" (Text field / checkboxes), controlled by field "category" with conditional fields module (shows only if laser printer selected).
Hierarchical Select settings for field "category" are: force to select deepest level, save only deepest level and no dropbox and no term creation allowed.
The problem is:
When a content is created and printers/laser is selected, the field "laser printer information" is not showed. If the hierarchical select category is changed AFTERWARDS to anything else, the field is displayed then (even though it should only display on printers/laser). If the category is changed again, the field is hidden again.
Does anyone have the same problem?
Comment #25
EndEd CreditAttribution: EndEd commented+1 for HS as controlled
Comment #26
EndEd CreditAttribution: EndEd commentedPlz, Could anyone tell me if HS as a controlled field is more dificult to get done in a patch than a Controlling field as the #8 patch ?
Also, is there a way to modify the #8 patch to get this kind of behavior (HS as a controlled field) ?
Thanks
Comment #27
momper CreditAttribution: momper commentedsubscribe
Comment #28
mirzu CreditAttribution: mirzu commentedI was able to modify the patch from above to work with the latest release attaching a new patch. I can confirm that this works with a hierarchical select enabled content taxonomy field that is controlling text and select fields. This patch would need to be cleaned up before it is rolled into the module, and I would be happy to do so if the maintainers are going to move in this direction.
Comment #29
g.k CreditAttribution: g.k commentedsubscribe
Comment #30
akin.demirci CreditAttribution: akin.demirci commentedThe #28 patch worked for me. I'm using hierarchical select in a content taxonomy field without dropbox.
THanks...
Comment #31
Aron NovakMostly works, but not perfectly.
I found the following bug:
Term hierarchy:
T1 - T2
T3
all of these terms above triggers a different textfield in my configuration.
If i select T1 then T2, the proper fields appear.
If i select T3, the proper field appears, BUT the field for T2 remains displayed, which is not proper behaviour. I'm sure the JS of the module can be modified to take care of the HS widget's specialities.
Comment #32
Aron NovakI re-rolled #28 and included some JS changes to only take care of a value when the form item is visible.
At this case, HS hides the not active selector, but not removes it. So the value from it is extracted by conditional fields.
Dropbox is still not covered.
Comment #33
Wim LeersInstead of supporting HS' dropbox functionality itself directly, you may want to enable HS' "render_flat_select" setting. This will result in an additional normal (yet hidden) select to be rendered with in there only the selected items in the hierarchy. That may be very handy…
Comment #34
Aron Novak@Wim Leers Thanks for the suggestion, seems to be a good way. However it does not solve all the problems, for example the Add and Remove operations has to be handled from Conditional Fields to support dropbox-style even if render_flat_select is turned on. I tried to implement a way, but no success yet.
Comment #35
Wim LeersOkay, then it's a bitch to support, I think.
I could add additional events to HS if that'd help. (See API.txt's "JavaScript events" section.)
Comment #36
drupalnesia CreditAttribution: drupalnesia commentedThese files contain both path #32 + path #18 from http://drupal.org/node/619290
#32: fix HS issue
#18 from http://drupal.org/node/619290: fix Content Profile issue
Both applied to CF 6.x-0-beta2, just replace with these files included (you must rename to conditional_fields.js and conditional_fields.module).
Comment #37
drupalnesia CreditAttribution: drupalnesia commented@Aron Novak:
I see:
Why you add
drupal_set_message("ee");
?Attached file with
drupal_set_message("");
only.EDIT: please read #38 before use this attachment.
Comment #38
drupalnesia CreditAttribution: drupalnesia commentedLatest patch (#32) doesn't work if using CCK + HS and save the value only to CCK field (not saving to node term). The patch only detect tids while the value will be saved to field_cck_field_name, thus make inconsistence, you can not use field_cck_name[0][value] when validate a node. Anyone experience same issue?
This won't work
EDIT: Also not work if a HS-field set to "Required", always error "Xyz field is required"
Comment #39
Encarte CreditAttribution: Encarte commentedsubscribing
Comment #40
ionmedia CreditAttribution: ionmedia commentedin my case HS controll many other cck fields and it is not working at all
Comment #41
loze CreditAttribution: loze commentedI have noticed that if HS is NOT set to save the term linage (save only deepest term) and the triggering value is a parent of the selected term, the controlled field is triggered (shown int he form) but no data is saved.
for example:
HS tree is a controlling field and something like: term A > term B > Term C
where term A is the triggering value for a cck field.
When the node is saved, the value of the textfield is not saved since only "term C" from the HS field is being saved and it is not a triggering value, although it is a child of the triggering value.
The temporary solution is to either have the HS field set to save the linage, or select every potential deepest level value as the triggering field.
I think CF should check if a parent value is set in the form, and save the triggered fields value.
Comment #42
BeaPower CreditAttribution: BeaPower commentedDoes this work with drupal 7?
Comment #43
amogiz CreditAttribution: amogiz commentedSubscribing for D7 !
Comment #44
pgrond CreditAttribution: pgrond commentedIt does not work yet for Drupal 7 as far as I know. Also see this issue http://drupal.org/node/1325538
Comment #45
fiveaces CreditAttribution: fiveaces commentedSubscribing for D7
Comment #46
ijujym CreditAttribution: ijujym commentedSubscribing D7
Comment #47
marcoBauli CreditAttribution: marcoBauli commentedD7 users should watch http://drupal.org/node/1325538 as pgrond points out. Seems patches above are no more compatible with latest versions of Conditional Fields and HS.
Comment #48
Helmut Neubauer CreditAttribution: Helmut Neubauer commentedsubscribe D6
Comment #49
Helmut Neubauer CreditAttribution: Helmut Neubauer commentedsubscribe D6 - Patch of #36 works for me (concerning the compatibility to Hierarchical Select). Is ist possible to add the changes to the dev version (to have them for the next update?) and to change the code according to #38 ?
Comment #50
peterpoe CreditAttribution: peterpoe as a volunteer commented