I'm using Hierarchical Select in a custom form being built with the CTools Form Wizard, and I'm running into an issue where Drupal's Form API isn't generating a #parameters option in the array, probably because of whatever CTools is doing to the form internally. Since hierarchical_select_json() uses the #parameters array to generate the form element upon update, it was giving me a "Received an invalid response from the server." I realize that this may be related to the numerous other issues dealing with this response, but I couldn't find a common thread in any of them to determine if this was related or not.
For documentation purposes, here is a list of (potentially) related issues...
#538022: JS alert: "Received an invalid response from the server."
#697172: "Invalid Response from Server", possible causes and solution
#784078: Incompatibility with formblock.module (node.pages.inc is missing): add node.pages.inc precautionary on all hs_taxonomy forms
Since grokking this module seemed simpler, I decided to attempt a patch here first. Patch to follow.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 931444-hs_ctools_wizard_bugfix.patch | 1.5 KB | Brandonian |
Comments
Comment #1
Brandonian commentedPatch sets $storage['parameters'] based on $_POST information, which in my use case is valid. Not sure how this will conflict with the subform_element problem described in the comment, but it should default to the prior version's implantation. There's still a potential fail if $storage isn't set and $_POST['form_id'] isn't set.
Comment #2
crea commentedConfirming and subscribing. I've noticed that too while working with the form wizard.
Comment #3
alekm commentedTrying to create a custom multistep form using the CTools form wizard
Same issue here, no answer found yet. CTools 1.8 with HS 3.6 & 3.x-dev. Patch above did not work.
Comment #4
Nick Lewis commented@Brandonian This patch didn't fix the issue for me either. There must be some configuration factors at play as well... Could you please share the wizard setup you used that got fixed by this patch?
Adding to the discussion...
The failure that causes this bug happens in the ahah callback function hierarchical_select_json(); (line 291 hierarchial_select module).
Specifically this process fails:
The issue is that the hierarchial select element doesn't get returned from form_builder(). There are many causes for this, most notably:
1. ctools wizard $form array doesn't return but is passed by reference. This could be partially solved by simply returning $form when when arg(0) == hierarchical select callback.
2. Even when you do return the form array it fails for some reason. This may have something to do with the fact that you can't call drupal_get_form('ctools_wizard_form') and expect it to work (but in some sense, that's what the callback is trying to do when it rebuilds the form element).
Seems like there's two routes to fixing this:
1. create a new callback that is compatible with ctools wizards (this I've explored - its not looking easy).
2. figure out why other ahah form elements work fine in ctools wizards but this one doesn't.
Comment #5
wim leersProbably it's mostly because HS uses:
- virtually all FAPI functionality and something trips up deep down in the FAPI dungeons of doom
- its own form cache (which was necessary to be able to work in Views exposed filters forms)
In any case, I won't be spending any time on solving this, because it's most likely an excruciating experience. It also seems to affect few people, so it doesn't seem to be very important (hence marking as minor).
Comment #6
vectoroc commentedsubscribing
Comment #7
wim leersClosing due to lack of response.
Comment #8
msumme commentedThis works w/ the ctools wizard... I just run some checks, and load the form from the form id instaed of the parameters...
Comment #9
msumme commentedAlmost forgot... w/ the code i just put up there, you'll need to have your ctools wizard function return something... which doesn't seem to be a problem.
Comment #10
ayalon commentedIn my case, I wanted to use node_form and hierarchical select together.
you have to add pages.inc to the files, that get loades, else you receive an invalid callback:
http://drupal.org/node/640534
$form_state['form_load_files'] = array(drupal_get_path('module', 'node') . '/pages.inc');
Comment #11
cosolom commentedProblem is still actual for D6 (6.28) + HS (3.8) + Ctools (1.10) and may not will be fixed. Additional info about proble can find here.
But you can setup your ctools wizard form in a way to work all.
Need write additional wrapper for form callback and on form wizard page write at the end of form:
It is very simple, but not obvious.