I know, this [potentially serious] bug/issue might be being launched a bit late. Surprisingly, I couldn't find anything online which indicates that Drupal7's Ajax system seems to have a problem with ->extend('PagerDefault') and ->extend('TableSort') in the default configuration. When clicking either on the pager or the table head elements (made sortable), the system returns following error message:
Undefined index: form_build_id in ajax_get_form() (line 320 of /var/www/devdev/drupal7/includes/ajax.inc).
includes/ajax.inc (line 320):
$form_build_id = $_POST['form_build_id'];
This means, quite obviously, that the POST variable 'form_build_id' cannot be found resp. is not available. I made several checks with my form: The 'form_build_id' becomes available e.g. straight after clicking a form element before the particular table (with the sortable header above and the pager below). Here comes the proof (;): form-h1Q-_7FcO8nFRRfueZSzHIMo7zLxs46_Uk5Wrhe6OS4 !
Straight after loading/rendering the pristine page/form [and without having clicked anything yet] via hook_menu()'s page callback the form_build_id does not exist. It doesn't matter whether the callback is . Anyhow, in my eyes drupal_get_form() or drupal_build_form()->extend('PagerDefault') and ->extend('TableSort') should work by default and shouldn't need any additional workarounds/additions. Am I wrong?
Comments
Comment #0.0
Blooniverse commented(ps) table deleted.
Comment #0.1
Blooniverse commented(ps) layout stuff.
Comment #1
Blooniverse commented... btw, I am aware of this old issue here: #295430: Default sort using tablesort_get_order() is broken. It seems to be still [or again?] haunting Drupal's tables! I, for instance, get a
Fatal error: [] operator not supported for strings in /var/www/devdev/drupal7/includes/tablesort.inc on line 172
when:
$arr_thead[] = array('data' => t('ZIP code'), 'field' =>'zPLZb', 'sort'=>'asc');... *sigh*
Comment #2
Blooniverse commentedPosting a hint about #97293: Tablesort cleanup - related to my comment#1!
Comment #3
tim.plunkettCan you post exact steps to reproduce?
If you wrote any custom code, can you provide that as well?
Comment #4
Blooniverse commentedHello Tim!
Thanx a lot for you quick response. I am very super-glad about your community service, I can tell you!
Well, it is actually quickly explained. After clicking on one of the table header titles, I get:
Notice: Undefined index: form_build_id in ajax_get_form() (Zeile 320 von /var/www/devdev/drupal7/includes/ajax.inc).
When I look at the table header titles, the message in the browser status is for instance
drupal7.dev/ajax?sort=asc&order=foo-title-- which looks wrong to me straight way, since it should beorder=foo, shouldn't it?Devel's Krumo backtrace points this out was well:
Below you find my module code.
Again, thanks a lot for looking into this [nasty] thing.
Comment #4.0
Blooniverse commented(ps) last layout changes.
Comment #5
acrussell commentedI am also getting this problem.
I am very surprised that it is unresolved! Either very few people are usuing ajax with tableselect (seems unlikely?)
or there is some workaround that I just haven't run across yet.
Below is an example which uses ajax and tableselect to reproduce the white screen of death problem I get.
The example is contrived and somewhat patched together but it reproduces the problem exactly it seems.
If you have the form recreated by typing something in the textfield and hitting enter and then click "next" you will get the white screen of death. If you click back Drupal informs you of the error
Notice: Undefined index: form_build_id in ajax_get_form() (line 320 of /var/www/html/includes/ajax.inc).
I notice that clicking "next" the URL changes to something which is clearly not right:
?q=system/ajax&page=1
Below is the module code. If there is some workaround to getting ajax and tableselect to work well together I would appreciate knowing what it is! This seems to me to be a fairly serious bug!
Comment #6
tim.plunkettFixing tags
Comment #7
acrussell commentedIs there any alternative or workaround (or even a tentative D7 patch?) that can be used while waiting for the backport?
I would like this functionality for a current project and this is an unforeseen bottleneck!
Comment #8
Blooniverse commented@acrussell: Have you tried the patch on http://drupal.org/node/97293#comment-5813270 (referred to in comment#2) already? If you do so, please let us know immediately about the outcome!!!
Comment #10
Blooniverse commented... yes, please let us know, @esprit2!
Comment #11
mazdakaps commentedSo what was the solution?
Comment #12
eMuse_be commentedI added these extra fields in my template (they seemed logical). Everything works for me:
print drupal_render($form['form_build_id']);print drupal_render($form['form_token']);print drupal_render($form['form_id']);print drupal_render($form['webform_ajax_wrapper_id']);Comment #12.0
eMuse_be commented(ps)
Comment #13
joshtaylor commentedRan into this today because I forgot:
Woops :).
Comment #14
pavlos.katsonis commentedI'm using Drupal 7 and have the same problem, but I don't understand where to put the 4 drupal_render commands. I don't have any templete file, just include files. The relevant code follows:
I would be grateful if you could point me to the right direction, since I'm quite new to Drupal development.
Comment #15
darth_revan43@yahoo.com commentedI've posted a workaround for this issue here for anyone who is struggling with this.
Comment #17
weeger commentedWork fine with #12.
Why not create a method for system required form field like drupal_render_form_header($ajax = FALSE); ?
Comment #25
pameeela commentedThere were never really any steps to reproduce here and it only seemed to be affecting custom code, so I'm going to close this.
If anyone still has the issue in D7 or D8 please open a new ticket with clear steps to reproduce, starting with 'Install Drupal'. If your issue only occurs with custom code, then it's probably a support request rather than a bug.