First I have to say my English is poor so apologize if I didn't make myself clear.
I've spent a whole day trying to find out why ahah doesn't work if there is a file input in the form. Finally I found it's jQuery caused this issue.
To reproduce this issue, first we need to enable jQuery update and overwrite /misc with files from 'replace' folder of jQuery update module. Install ahah_helper module which we can make the testing a bit easier. I have tested not using ahah_helper so the issue does not caused by ahah_helper.
Then, we create a module called jqup and use the following code in .module(not tested the code but just want to show the idea how to test):
function jqup_menu() {
$items = array();
$items['test'] = array(
'title' => 'jQuey update issue',
'page callback' => 'drupal_get_form',
'page arguments' => array('jqup_test'),
'access callback' => TRUE,
'type' => MENU_CALLBACK
);
return $items;
}
function jqup_test() {
drupal_set_message(print_r($_POST, true));
$form = array();
$form['option'] = array(
'#type' => 'radios',
'#title' => t('Option'),
'#options' => array(1,2),
'#default_value' => 0,
'#ahah' => array(
'event' => 'change',
'path' => ahah_helper_path(),
'wrapper' => 'not-needed'
),
);
$form['fid1'] = array(
'#type' => 'file',
'#title' => t('File 1'),
);
return $form;
}
After that we enable the test module, go to /test. When we click any of the option, the $_POST variable should contain values from all form items. But now when jquery update is enabled $_POST variable isn't correct, it just contains some hidden values which provided by FORM API itself. It's not correct. If we change #type for the second form item to something like #textfield, then it works again. Please let me know if you need more information. I'm willing to help :)
Thanks,
Andy
Comment | File | Size | Author |
---|---|---|---|
#43 | jquery_update-upgrade_jquery_form-806500-43.patch | 45.86 KB | bdlangton |
#37 | jquery_update-AHAH_fix-806500-33.patch | 25.73 KB | mrjmd |
#25 | cck-compound-field.png | 27.94 KB | mplewis |
#19 | 806500_jquery_update_ahah_js_clone.patch | 1.8 KB | smoothify |
#11 | 806500_9-no-disable.patch | 1.33 KB | deviantintegral |
Comments
Comment #1
andyhu CreditAttribution: andyhu commentedDuring my research I found that Drupal's ahah.js doesn't work with jQuey current version. Is there any way to fix?
Comment #2
mfer CreditAttribution: mfer commentedYou do not replace files in /misc. Just install and enable jQuery Update. In the replace folder there is an ahah.js that works.
Comment #3
HylkeVDS CreditAttribution: HylkeVDS commentedI've just been debuging #860966: Create Content - Book Outline - Book: Select Drop Down AHAH form does not show Parent Item and I tracked it down to this:
modules/jquery_update/replace/ahah.js line 121:
Disables the element that triggered the post, resulting in that element being removed from the post entirely. Apparently this changed in jquery between the version in Drupal 6 and the version in jquery_update, as the same line is also in the ahah.js of Drupal 6.
Commenting out that one line makes the book form function just fine again, and I suspect it will also fix this issue. Did the order of things change? (first post, then disable?)
Comment #4
dan.nsk CreditAttribution: dan.nsk commentedI can confirm this issue even without replacing the files
Comment #5
skolesnyk CreditAttribution: skolesnyk commentedIt's a critical issue -- what to do? Use stable ver?
Comment #6
HylkeVDS CreditAttribution: HylkeVDS commentedYou can try to see if my suggestion of removing that one line fixes the problem for you. If it does it's a good lead for the maintainers as to what the problem really is.
Comment #7
skolesnyk CreditAttribution: skolesnyk commentedThanks, Hylke! Looks like that 'fixes' it.
Comment #8
smoothify CreditAttribution: smoothify commentedI was experiencing this issue too when using my module AHAH Dependent Fields.
Took me half a day to locate the bug to this module and its ahah.js.
Commenting the line mentioned in #3 fixes it for me.
[Changing this to a bug report as it does break other modules just by installing this module]
Comment #9
smoothify CreditAttribution: smoothify commentedAfter a bit more research the issue seems to be caused by a change in jquery.form.js which now no longer submits fields that are disabled
Looking at Drupal 7, it seems to use the beforeSend event instead of beforeSubmit. I tried D7's approach with this module along with the latest jquery.form.js, but it still exhibited the problem.
So for now here is a patch with the element disabling removed.
Comment #10
smoothify CreditAttribution: smoothify commentedAnd here is an alternative patch to #9 - this one swaps the disabling of the element with a read only setting. This works and at least on some form element types prevents editing.
Comment #11
deviantintegral CreditAttribution: deviantintegral commentedI ran into this issue with a custom module for a site I'm working on. According to the HTML specs, disabled elements shouldn't be submitted, so likely the older jQuery or jQuery.form shipped with Drupal 6 is breaking spec. Strangely, it looks like it was Firefox's .submit() method that was actually ignoring the element, not any of the JavaScript up to that point.
I've attached a patch that hides the element instead of disabling it.
Comment #12
Bartezz CreditAttribution: Bartezz commentedTested #11 and all bugs with AHAH calls I had are completely gone now.
This is a critical bug as it breaks sites and admin forms, therefor marking it as critical.
Thanx more than a bollion deviantintegral... this bug was killing me! And it being Blue Monday I couldn't handle much more :)
Cheers
Comment #13
smoothify CreditAttribution: smoothify commentedI have run into some issues with patch #10, which can cause the 'Add more' button not to function correctly.
Patch #11 does work fine, and seems to be the way to go here. Ideally i'd prefer not to have hide the element, as it can be confusing in the UI, but its better to do this i feel than leaving it visible and active.
Comment #14
deviantintegral CreditAttribution: deviantintegral commentedCompletely missed the patches by smoothify - yay cross posting.
The worst part about what I've done in #11 is where we had some inline select boxes. I ended up setting min-width based on the actual width of the element (since that depends on font and browser). Works with any decent browser and IE7+. So, there are display issues with hiding the element, but at least you can submit the freaking form. I think it's probably best to use this approach but also document it as this could mess with all kinds of other modules.
Comment #15
jimajamma CreditAttribution: jimajamma commentedI ran into this last night using the 1.1 version when I saw the throbber spinning round and round when I tried to delete a file I'd uploaded, and of course thought it was something I had done elsewhere (I had hacked up transliteration a bit lol), but finally tracked it all down to here, too (which I have hacked up to go to microsoft and/or google for the file instead of locally, but that's another story). Anyways, my quick fix back in the day was to just update jquery on non admin pages, but now I see I have to do it on edits and adds as well. So, my new quick fix is to add "if(arg(0)=='admin' || arg(1)=='add' || arg(2)=='edit') return;" to the beginning of jquery_update_preprocess_page() which I am sure will bite me down the road again, too :)
Jim
EDIT:
of course, upgrading to the 6.x-2.0-alpha1 version just now fixed everything without any of those bite you in you know where hacks I mentioned above...silly me.
Comment #16
deviantintegral CreditAttribution: deviantintegral commentedFixing the version of this issue. If needed, we can get this backported to 1.1 after it's committed.
Comment #17
smoothify CreditAttribution: smoothify commentedI also ran into the inline fields issue with patch #11 - this can be common when using multiple fields since that uses inline-block as a display style, which with this patch gets swapped for display: block when the show function is called.
I haven't used D7 much, but I know it still uses the disable method we are trying to avoid. Curious, I looked into the POST response that is fired, I notice that it also sends the following two post values with the response - 'triggering_element_name' & '_triggering_element_value' - This does of course go much further into the new ajax system of D7 and out of the scope of jquery_update.
Comment #18
bmhaskar CreditAttribution: bmhaskar commentedThanks a ton..!!
This worked for me...
We were trying to fix this since a few days...
Updating to the jquery_update alpha 6.x.2 served our purpose.
Hope this doesn't break anywhere else.
Comment #19
smoothify CreditAttribution: smoothify commentedHere is an experimental patch for this problem:
This patch keeps the disabled behaviour of the element and instead creates a hidden input with the the correct name and value so the correct data gets submitted as usual. The hidden input is removed once the submit is complete.
So far its working for me with buttons, text & select elements, and avoids the UI moving around as in patch #11.
Comment #20
Bartezz CreditAttribution: Bartezz commentedSorry, finishing up the website for presentation. don't have the time to test your latest patch. Can only confirm that the patch in #11 by deviantintegral works for me.
Cheers
Comment #21
deviantintegral CreditAttribution: deviantintegral commentedI tested #19, and it breaks when you have a select with an empty value in #options:
Once you select a non-empty value, and then select the empty value again, #ahah breaks entirely and the form never changes.
Comment #22
svdhout CreditAttribution: svdhout commentedpatch #19 worked fine for me.
@ #21: is it a good idea to use an empty key, and a zero key?
Comment #23
gooddesignusa CreditAttribution: gooddesignusa commentedpatch #19 worked for me. I can now upload images in safari via cck imagefield. Finally :) Thank you
I still see this error in my console inside Safari's Web Development:
But it still works.
Comment #24
deviantintegral CreditAttribution: deviantintegral commentedUsing an empty key is the only way to have a #required selection dropdown, where the user has to make a choice. As for using zero as a key, it doesn't have any affect one way or another on the patch, and is pretty common though normally used in the numeric, and not string form as in my example.
Comment #25
mplewis CreditAttribution: mplewis commentedComment #3 worked for me, but I ran into problems with my custom CCK field.
I followed this tutorial to create a "compound field", where each field has multiple sub-fields (see attached screenshot):
http://www.poplarware.com/articles/cck_field_module
My CCK field has several sub-fields including an AHAH-enabled select box. Unfortunately, after installing Jquery Update and upgrading to Jquery 1.3, the select box values were no longer being passed to my AHAH callback function (because ahah.js disables the select box until the request has finished). So, my sub-fields were not being dynamically populated.
Instead of commenting out line 121 of ahah.js, I wrapped it in an if statement, so that only "submit" elements will be disabled:
I hope this helps someone!
Comment #26
deviantintegral CreditAttribution: deviantintegral commentedI went to try and fix the issue I mentioned earlier, but I can't replicate it anymore. So, I say #19 should be committed and we can do a followup issue if needed.
Comment #27
drmonkeyninja CreditAttribution: drmonkeyninja commentedJust been tackling this issue myself and agree the patch in comment #19 worked a treat. Should be committed.
Comment #28
csc4 CreditAttribution: csc4 commentedSubscribing - was about to put colorbox on a 6 site and need jquery_update 2 but not sure if should until this patch is committed?
Comment #29
cremers CreditAttribution: cremers commentedSubscribing - Six dev still doesn't fix it. Would use jquery_update for the drupalchat module.
Comment #30
notluap CreditAttribution: notluap commentedI am also having this problem... cck file uploads are broken when Jquery Update is enabled. However, patch #19 or upgrading to the latest dev has not fixed it for me.
Comment #31
xger86x CreditAttribution: xger86x commentedI'm still using the jquery update version alpha but when i use a file field i can't invoke ahah. I've tried the patches above but they don't dix the problem. any idea please? I'm getting frustrated
Comment #32
jvieille CreditAttribution: jvieille commentedFramework does no longer fire automatic previews with JQuery update.
http://drupal.org/node/688538
Comment #33
Yoran CreditAttribution: Yoran commentedJust replacing provided jquery.form.js by the last one from github (https://github.com/malsup/form) solved this issue for me.
Comment #34
bali001 CreditAttribution: bali001 commentedand solved my problem too
thx :)
Comment #35
davidshaw CreditAttribution: davidshaw commentedPatching ahah.js by following patch #19 here fixed my custom ahah form text field not keeping its values unless the form file field had been uploaded first.
Similar conflicts were occurring with CCK imagefield and CCK filefield. This patch to ahah.js seems to help with all of them.
I have also updated my callback to use drupal_to_js instead of drupal_json when printing the callback status and data but this didnt seem to make a differene:
http://drupal.org/node/399676#comment-1438662
Comment #36
elioshI can confirm that using updated jquery.form.js (3.03 - 08-MAR-2012) as suggested by Yoran in comment #33, fix the problem.
(I'm using version = "6.x-2.0-alpha1+7-dev" and jquery 1.7)
Comment #37
mrjmd CreditAttribution: mrjmd commented#33 worked for me as well. Rolling a patch.
Comment #38
jrockowitz CreditAttribution: jrockowitz commentedThe patch for #37 worked for me but I am little unsure how the new js code should be formatted. For example the existing code has some line breaks and the patch does not.
I think one of maintainers will have chime in on how the JS code should be compressed and formatted.
BTW, the patch fixed this issue #860966: Create Content - Book Outline - Book: Select Drop Down AHAH form does not show Parent Item but I am not sure if it might break something else.
Comment #39
jrockowitz CreditAttribution: jrockowitz commentedSo I did a diff of the jquery.form-2.43 and jquery.form-3.09.js can see that the changes between the 2 versions is so great that it is too risky to update jquery.form.js to a new version.
Patch #19 is the safest fix and should probably be committed.
Comment #40
Rajesh Ashok CreditAttribution: Rajesh Ashok commented#33 solved my issue. Thanks.
Comment #41
agalitsyn CreditAttribution: agalitsyn commented#33 works for me, pressflow 6.25
Comment #42
TajinderSingh CreditAttribution: TajinderSingh commentedReplacing the jquery.form.js in replace folder of jquery_update module worked perfect as mentioned in #33
Thanks a lot as saved my life :)
Comment #43
bdlangton CreditAttribution: bdlangton commented#33 worked for me too. Just upgrade to a newer version of jquery.form.js. Here is a patch to do that for version 3.04.
Comment #44
dsnopekLatest patch in comment #43 is working for me on two seperate sites!
Comment #45
budalokko CreditAttribution: budalokko commentedLatest patch in comment #43 solved the problem for me too.
Comment #46
curlymike CreditAttribution: curlymike commentedAfter installing jQuery update 6.x-2.0-alpha1 some AHAH forms of mine got broken.
It seems that when form submission is triggered by AHAH checkbox of dropdown menu or something like that the triggering element retains it's old value, because the element being disabled on preSubmit step. Updating jquery.form.js to version 3.17 - last one compatible with jQuery 1.3.2 solved the problem for me. Got it here https://github.com/malsup/form/tree/16022a3171f858845c877db3a74362f3d193... don't know if there is a better way to obtain it :-)
Comment #47
dsnopekThe patch on #43 fixed this for all browsers including latest Chrome, Firefox, IE8 and IE10 - but NOT for IE9. I tried using jquery.form.js version 3.17 per @curlymike's comment in #46, but it didn't fix the problem unfortunately. Everything is working but IE9!
Comment #48
aitala CreditAttribution: aitala commentedAnyone know where to obtain jQuery Form Plugin V3.04 these days?
E
Comment #49
rv0 CreditAttribution: rv0 at Coworks.be commented@aitala it's part of the patch in #43
Comment #50
aitala CreditAttribution: aitala commented@rv0 - I see that now, but that did not work. I reverted to an earlier version of the module which has solved the problem.
Thanks,
E
Comment #51
markhalliwellDrupal 6 reached EOL (end-of-life) on February 24, 2016.