Closed (fixed)
Project:
Hierarchical Select
Version:
6.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
6 Oct 2009 at 21:24 UTC
Updated:
28 Oct 2009 at 14:40 UTC
Everything works fine when using hook_form - like Wim does in his hs_tutorial module. However when i use hook_form_alter (instead of hook_form) i get a "Received invalid response from the server" error after selecting a root level item. Reloading the page then yields a drupal error: "warning: uasort() [function.uasort]: The argument should be an array in /home/fivthwor/public_html/imaginariums/includes/common.inc on line 2875."
I tried giving the module different weights, disabling contrib modules, clearing and flushing caches - to no avail.
Please see attached module file and i can provide a screencast if necessary.
Comments
Comment #1
Hunabku commentedModule file:
Comment #2
wim leersInstead of generating the hierarchy in custom_add(), generate it in imaginariums_test_hierarchy() and use a static variable to generate it only once. That might help.
Comment #3
Hunabku commentedWim - thanks for your timely response
I went ahead and put the internal_hierarchy array generating code back into imaginariums_test_hierarchy() static array - where it belongs. : )
I also removed the menu_alter and custom_add callback from my modules code. The error persists.
Have you found no problem using a hook_form_alter instead of a hook_form with your example code?
hook_form_alter seems like a fairly common place for implementing hs api for non-taxonomy use cases. Ergo is there anyone else out there who has done this successfully?
Comment #4
Hunabku commentedOK - substituting form_alter for form works fine with hs_tutorial module. There is something specific to what i am doing that is creating the error - perhaps i'll post what is causing it incase someone else bumps up against it.
THANK YOU Wim for an awesome module and great support.
Comment #5
Hunabku commentedRiddle me this ???
Everything works fine after i removed the following if statement from my hook_form_alter:
if (arg(1) == "add") {}
what that has to do with HS i have no idea - i'm just glad i got it working : )
Comment #6
wim leersAhhh, of course! The arg(1) is NOT equal to 'add' when updating HS, since HS uses a callback to a different path for that.
Glad you got it solved :)
Comment #7
Hunabku commentedHi Wim
Sorry to reopen this but i really need to execute different hierarchical select depending on arg(n).
i tried to create and use my own uri args but it makes no difference.
$uri_args = explode('/', substr(request_uri(), 1));Do you think there is anything you could do to hs to make it more amiable to the arg . . . . .
or anything i could do on my side?
Comment #8
wim leersThere's nothing I can do. That's how it works.
What you could do, is add a GET argument. E.g. node/add/page?bleh=whatever. This will be carried on.
If it is the adding of nodes you want to detect, there's other ways to do that. For example, check if a node object is present. If not, a new node is being created, if it is, an existing node is being edited.
Comment #9
Hunabku commentedOK - I'll add the GET
mahalos!