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

matthewtrow’s picture

Getting the same issue.

grahamc’s picture

I'm seeing this too - looks like Clientside Validation is trying to use the accept method, but:

  1. Accept is now mimetype based - the filename based version has been renamed to extension
  2. Both were moved to the additional-methods.js file, which we don't currently have.
barraponto’s picture

Please 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.

barraponto’s picture

Status: Active » Closed (duplicate)
grahamc’s picture

Status: Closed (duplicate) » Needs review
StatusFileSize
new40.71 KB

This 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.

barraponto’s picture

@grahamC there have been changes since 1.38
Did you try with the latest dev? Can you provide steps to reproduce the error?

grahamc’s picture

Title: Uploading Files produces Ajax error » Uploading Files produces JS error
Version: 7.x-1.38 » 7.x-1.x-dev
Status: Needs review » Needs work

OK, 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, namely result = $.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)

barraponto’s picture

Great. Is that 40k patch required to fix that JS error? Does it still apply?

torotil’s picture

Status: Needs work » Needs review
StatusFileSize
new40.19 KB

@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.

grahamc’s picture

Digging 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?!

attiks’s picture

I 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

attiks’s picture

Status: Needs review » Fixed

file extension validation is disabled, I opened #2184745: Decide how to add the additional validation methods to decide on how to add the additional methods

ardeso’s picture

Thank you :)

Status: Fixed » Closed (fixed)

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