While creating the plupload widget (http://drupal.org/sandbox/vingborg/1138512), I realised that the plupload form element requires at least one file when it is submitted.

The attached patch fixes that issue against the master. It's for Drupal 7 only, but backporting it to the Drupal 6 branch should be trivial.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vingborg’s picture

This is the same patch as above, but against the latest revision in the repository (update this morning).

greggles’s picture

It would be great to get review from one of the 7.x maintainers on this.

Based on vingborg's work at http://drupal.org/sandbox/vingborg/1138512 I am inclined to trust it and will consider committing it with a proper review from someone using the 7.x branch.

Scott J’s picture

I have been using this patch on D7, and it does fix the issue, and doesn't seem to cause any other problems.

David_Rothstein’s picture

Can you clarify how you tested this in D7? I tried this with Media, and although it allowed the "upload" to proceed with no files, the plupload browser never winds up closing, leaving the user in a confused state. I think that may be an issue with Media itself (more than this patch) but since I don't know of anything else this module integrates with in D7, I'd be hesistant to commit it until we figure it out :)

The basic approach looks fine, though, so if the code works in D6 it's certainly reasonable to commit there.

Meanwhile, I rerolled the patch (attached) to fix a couple small issues:

  • Removed some duplicate logic.
  • Avoided a PHP notice in the case where $element['#required'] is not set.
sidney’s picture

I'm using this in D7 with the mupload sandbox module http://drupal.org/sandbox/vingborg/1138512

I just made a content type with an image field set to allow unlimited instances and gave the field a widget type of muploader. Without this patch editing the body text of the page or the alt text of a existing image in the image field and trying to save would result in an error message about at least one file upload being required.

Fidelix’s picture

None of these patches apply to the dev version of plupload.

rv0’s picture

Category: task » bug
Priority: Normal » Major
FileSize
3.05 KB

Rerolled the patch, structured the javascript a bit differently.
Why weren't the previous patches committed?

(patch created at Coworks)

attiks’s picture

Status: Needs review » Reviewed & tested by the community

#7 works like a charm

sachbearbeiter’s picture

is it commited to dev now?

janadam’s picture

#7 works for me too

jsheffers’s picture

Everything works for me, but I get an error message when removing images.

Notice: Undefined index: 1 in file_ajax_upload() (line 265 of /home/mysite/public_html/modules/file/file.module).
Notice: Undefined index: #suffix in file_ajax_upload() (line 274 of /home/mysite/public_html/modules/file/file.module).

It doesn't seem to effect the functionality and the image deletes correctly, but it's not good for a user to see that kind of error. Any ideas. I have Plupload 7.Dev with the patch from number 7.

mrryanjohnston’s picture

Same issue as #11, except after deleting, all of the pictures are removed except for the last one in the queue.

tomfilepp’s picture

Has this been committed to the project on any level? I'm having some whitespace issues applying this patch to the May 25th dev.

rv0’s picture

@tomfilepp
Did you use the patch in #7?
weird that nobody reported the whitespace + that it hasn't been committed.

jacks0_0’s picture

Same issue as #11, using dev version of pupload and applied the patch #7

jsheffers’s picture

This solution works for me, but there is still an Ajax error when removing images, and drag to reorder is nor functioning correctly either. It allows you to drag it, but it won't let you "put it down." When you finally do get it in the right order, it doesn't show that way on the node.

kytom’s picture

I have the exact same problems as #16. When dragging, releasing mouse does nothing - image still gets dragged and I have to click the arrow icon again to let it go.

More importantly however, even if I reorder them, the change isn't reflected in the node. I come back to the edit page and the changes aren't saved. Is there any way to make this work, some workaround perhaps? This is somewhat of a crucial functionality for me.

slashrsm’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
3.16 KB

Attached patch is basically the same as #7. I just deleted some whitespace in empty lines, added another comment and added missing Drupal.t() around a string in .js. Please check if you agree with the changes.

As regards ajax errors: Could this be a Mupload issue? I get the same errors with Plupload 7.x-1.x with and without this patch. On the other hand I do not get any errors using Filefield sources Plupload: http://drupal.org/sandbox/atlea/1414774. That makes me think that Mupload causes this issue.

Since it looks like ajax errors have nothing to do with this patch itself, I'd recommend calling this RTBC as soon as someone gives this last patch a review. We can open another issue about ajax errors. Does this sound OK?

rv0’s picture

In case anyone hasn't noticed this module yet: http://drupal.org/project/plup

I've been using it in latest projects

mr.york’s picture

Multiple plupload form elements incorrectly detected which required.
Small fix.

slashrsm’s picture

Status: Needs review » Closed (duplicate)

It looks like commited patch from #1414486: Allow for Multiple Plupload elements in a form fixed that issue also.