Can AHAH helper be used at the same time as hierarchical select?
| Project: | AHAH helper |
| Version: | 6.x-2.0 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Hi,
I am in the middle of developing a node module that uses various forms to enter details about the nodes. I am a long-time user of hierarchical select under Drupal 5 though this is the first time I have used it under Drupal 6. I've been experimenting with the AHAH helper module to make context-dependent parts of my form show up according to selected input elsewhere.
I've run into problems trying to use a hierarchical select picker as one of the optional form elements - by which I mean that the HS element is only shown after a different selection is made elsewhere on the form and the container for the HS element is shown as part of the AHAH callback. So the HS element was not part of the initial form, it was added later. I get the display in HS that indicates that javascript is not enabled.
I wanted to ask if this is a known issue - should I not be trying to use both these modules on the same form? If you think this should work, I will put together a minimal test module and see if the problem can be tracked down further, but I wanted to know whether adding a HS item to a form after the initial form render could exhibit any problems.
Thanks for both of these really useful modules, Wim.
Paul.

#1
Well... six weeks and no reply so I thought I'd post an update :) I was having various problems with trying to use a hierarchical select form item on the same form as a fieldset that was to be updated by AHAH. I wanted the selection from the HS widget to trigger what appeared in the fieldset. I discovered that HS form fields don't take any notice of the '#ahah' definition, and also that when the AHAH helper was enabled on the form, it interfered with the Hierarchical Select widget so that the later didn't initialise its javascript and ended up giving the on screen message about javascript not being enabled. I was unable to find out why this was, not too surprising as I'm not really a JS programmer.
Eventually I came up with a hack or workaround (depending on how generous you are feeling). I bound the change-hierarchical-select event of the HS widget to a javascript function that did something like "$('#my-switcher-wrapper :input').trigger('change');" where my-switcher-wrapper was a div containing a textfield that was styled to be invisible. This textfield has a #ahah definition that posts to a callback function that I implemented using the old fashioned "by hand" method of AHAH in Drupal 6 as described at http://drupal.org/node/331941
This now works -- when the user changes the selection in the HS form item, the appropriate part of the form then is re-rendered according to the selected item.
#2
hi did you manage any other way to use both ahah helper and hs together. i got the problem with hs after i the ahah callback is submitted on the same form. i get an error of invalid response from server when i try select anything from hs.