It seems the example works ok on configuration form, but not on node add/ edit. In hierarchical_select_ajax() list($form, $form_state) = ajax_get_form(); isn't able to get the right form -- it seems the form_build_id is wrong.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Status: Active » Postponed (maintainer needs more info)

Huh? How is it possible that the most basic thing is failing?

Can you reproduce this on a vanilla Drupal site?

amitaibu’s picture

With plain vanilla install (7.0 release, I'll soon try with dev as-well) and only HS-taxonomy installed -- it doesn't work.

amitaibu’s picture

Status: Postponed (maintainer needs more info) » Active
FileSize
98.15 KB

Also with drupal 7-dev, it doesn't work. I've attached a dump of the DB

Wim Leers’s picture

Thanks for reporting back. That's very strange. I'll try to reproduce it.

Owen Barton’s picture

Status: Active » Needs review
FileSize
1.18 KB

I had the same problem, the form is not actually in the cache_form table, so there is nothing to retrieve - the issue is that hierarchical select is not setting the form to cache, or including ajax.js (yet it does use this function). It currently only works if another module (for example a multiple value field module) has done this already, which may explain why this is a little hard to detect.

Initially I received first a Javascript error (since ajax.js was missing), and after I fixed that an blank AJAX response, with a watchdog log of "invalid POST data" due to ajax.inc being unable to retrieve the form cache (since it was not stored).

Attached patch fixes this for me.

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

Awtch. Quite stupid of me. I've always tested with a content type that has a File Field — to make sure I don't break it. I should also have tested without it, and then I'd have noticed this. Thanks, Owen! :)

bigsyke’s picture

Patch #5 fixed it!

JVA-1’s picture

Patch #5 worked for my D7 too. Good job guys.

JVA-1’s picture

It seems fine in editing and viewing, but gives the notice mentioned earlier when adding/editing a field to any content type.
admin/structure/types/manage//fields/body

fietserwin’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.1 KB

These js files are libraries,so i think they should be included like this (see e.g. ajax.inc line 655/656):

  $element['#attached']['library'][] = array('system', 'jquery.form');
  $element['#attached']['library'][] = array('system', 'drupal.ajax');

Looking at ajax.inc, can't this be triggered by using the "#ajax' attribute on the element? (probably at the same time replacing some other lines of code with declarative settings) (http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....)

Adam S’s picture

Patch on #10 works for me :)

Owen Barton’s picture

Status: Needs review » Reviewed & tested by the community
silkscreen’s picture

Many thanks to the author for getting this up and running in D7. It is an invaluable module.

slashrsm’s picture

I can confirm that patch at #10 works.

Caution: patch at #5 also worked for Drupal 7.0, but it stoped working at 7.2.

fearlsgroove’s picture

FileSize
1.14 KB

Reroll of #10

fred0’s picture

Not sure this is related, but even after this patch, I am getting an invalid response from server error on the page and this in my apache error.log:
File does not exist: /var/www/mysite/hierarchical_select_ajax, referer: http://10.211.55.11/mysite/?q=node%2Fadd%2Fasset&render=overlay

fearlsgroove’s picture

@fred: you need to enable clean URLs. Not sure if HS is supposed to require clean URLs or not -- it should work without. But it should be a separate issue.

fred0’s picture

@fearlsgroove: Thanks!

hubScrappy’s picture

Still a bug somewhere here, after Patch/Line #15 ... I have a content type that has two Select Lists ... one for Location (Country -> Province / State -> City) and the other for Category ...

When I go to 'Add Content', as can be seen in the first attachment, both select lists show up fine ...

If I select Country, though, the view changes to what is seen in the second screen shot ...

Ignoring that problem, and choosing yet another time, one of the select lists then disappears, and, choosing another with just the remaining select list, I can actually now start choosing items ...

So, I guess the first question is: should I be able to do this twice on the same 'Add Content' form, or is that my mistake right there ...

Assuming that I am correct in how I'm trying to use it ... what more information can I provide towards debugging it?

I am running Drupal 7.2, with Hierarchical Select 7.x-3.0-alpha1 ...

Thx ...

fearlsgroove’s picture

@hubscrappy: Sounds like a different bug. Please open a new issue.

artatac’s picture

when I pplace this patch in the module folder and add the following in terminal I get


joes-imac-5:~ joe$ /Users/joe/hierarchical_select patch < hs-1069368-15.patch
-bash: hs-1069368-15.patch: No such file or directory

will this be added to the dev version soon?

fietserwin’s picture

Apparently, your file is not in the directory where patch is run. Try to place it in the hierarchical_select directory under modules. The patch expects this as the directory hierarchical_select is not part of the filename.

univate’s picture

Thanks, this issue was bugging me as it was working on an admin account but not for normal users. The difference in my case was that I had a filefield that shows up for admin's and not normal users.

Wim Leers’s picture

Title: Form isn't valid in ajax call » HS does not enable caching of the form it is in
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.