I'm using Clientside Validation 7.x-1.38, Webform 7.x-4.0-beta1, Webform Validation 7.x-1.3 and jQuery Update 7.x-2.3 (jQuery 1.8 selected).
I have a a webform with a field that allows a single image to be uploaded. The selection works, but if I click upload, I get an AJAX error.
"An error occurred while attempting to process /file/ajax/submitted/images_doc/form-lUpGwRwcVnklp7TFNLQoBusP-tYQMGutlqVA2A-FHEk: $.validator.methods[method] is undefined"
If I just submit without uploading first, the image is uploaded properly. If I remove the file there is no error.
Any help would be greatly appreciated, thanks!
Comments
Comment #1
matthewtrow commentedGetting the same issue.
Comment #2
grahamcI'm seeing this too - looks like Clientside Validation is trying to use the
acceptmethod, but:extensionComment #3
barrapontoPlease try the dev release.
I believe this issue has been fixed by #2056219: General problem with drupal AJAX requests prevented by clientside validation.
If it still happens, please reopen this issue.
Comment #4
barrapontoComment #5
grahamcThis isn't Clientside Validation preventing the AJAX request, this is a javascript error because of a change in the jquery-validation library.
I fixed it on our client's site with the attached patch... it could be a bit more sophisticated about when to load the additional methods, mind.
Comment #6
barraponto@grahamC there have been changes since 1.38
Did you try with the latest dev? Can you provide steps to reproduce the error?
Comment #7
grahamcOK, so trying with latest HEAD upload works fine, as does file extension validation. Yay!...
...But there's still an error output to the JS console,
Uncaught TypeError: Cannot call method 'call' of undefined, on line 542 of jquery.validate.js, namelyresult = $.validator.methods[method].call( this, val, element, rule.parameters );which is the same issue that my patch was aimed at.I don't have a clue how the validation is working in spite of this error : )
(to reproduce: I just enabled clientside_validation_webform, created a new Webform, added a File component, enabled validation for that form using the default settings)
Comment #8
barrapontoGreat. Is that 40k patch required to fix that JS error? Does it still apply?
Comment #9
torotil commented@grahamC: with latest HEAD the upload works because the broken validation has been disabled by default (see #2056219: General problem with drupal AJAX requests prevented by clientside validation). It hasn't been fixed though.
@barraponto: Yes. clientside validation bundles jquery.validation.js (which is deprecated) and was missing a file. Adding that file makes the patch so large.
I've found another issue with this patch: If JS aggregation is enabled we need weights in drupal_add_js() to guarantee that additional_methods.js is loaded after jquery.validation.js.
Here is an updated patch.
Comment #10
grahamcDigging to see why validation still appears to work, I discovered that Drupal has built-in client-side validation for file widgets (Drupal.file.validateExtension).
So I vote for ripping out extension validation from clientside_validation_webform ... and to the casual observer that seems to be the only place that was using it in the first place?!
Comment #11
attiks commentedI had a look at this, but I think it's better to not use the one big additional file, but instead only include the ones we need.
I removed the code in _clientside_validation_set_extensions for the moment so it no longer breaks
Comment #12
attiks commentedfile extension validation is disabled, I opened #2184745: Decide how to add the additional validation methods to decide on how to add the additional methods
Comment #13
ardeso commentedThank you :)