I'm using plupload with the mupload module, which allows me to use plupload as a file field widget. When I'm doing something else with the already-created files in the field, such as removing them, this causes the form elements to be replaced via AJAX. When this happens, the plupload behavior triggers again and successfully because the newly created plupload-element doesn't have the 'plupload-init-processed' class. However, the form element surrounding this field hasn't been replaced, so later on when the $form.submit handler is applied, it's basically applied a second time.

This becomes quite apparent after deleting a file, and then trying to submit the form, as you get two javascript alerts that 'You must at least upload one file.'.

The solution is pretty simple - just slip another 'once' call between the $form and the submit, as my patch will show.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jcfiala’s picture

And now that I know what the issue number is, here's my patch.

axe312’s picture

Assigned: Unassigned » axe312
Status: Active » Needs review
axe312’s picture

Status: Needs review » Reviewed & tested by the community

patch is working correctly.
plupload still says 'You must at least upload one file.', but only once, not multiple times.

http://drupal.org/node/1146562#comment-4934678 also corrects this bug and no messages will be displayed (if there is at least one file left in the mupload widget)

Both patches cannot be applied at the same time, but the patch above can be easily applied via hand (just 2 lines of code to add)

--> The problem is solved and should be commited to the core

slashrsm’s picture

I agree. I just corrected indentation of one line. RTBC

axe312’s picture

Patch is working correctly!

slashrsm’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

  • Commit ce9727a on 7.x-1.x, 7.x-2.x, 8.x-1.x by slashrsm:
    Issue #1316438 by jcfiala, slashrsm: Plupload in AJAX call causes form....