diff --git a/plupload.js b/plupload.js index f8be4d1..d98f3ac 100644 --- a/plupload.js +++ b/plupload.js @@ -58,11 +58,10 @@ Drupal.behaviors.plupload = { $form.submit(function(e) { var uploader = $('.plupload-element', this).pluploadQueue(); - // Only allow the submit to proceed if there are files and they've all - // completed uploading. - // @todo Implement a setting for whether the field is required, rather - // than assuming that all are. - if (uploader.files.length > 0 && uploader.total.uploaded == uploader.files.length) { + // Allow the submit to proceed if there are files and they've all + // completed uploading, or if there are no files and the field is not + // required. + if ((uploader.files.length > 0 && uploader.total.uploaded == uploader.files.length) || (uploader.files.length == 0 && !pluploadSettings.required)) { // Plupload's html4 runtime has a bug where it changes the attributes // of the form to handle the file upload, but then fails to change // them back after the upload is finished. diff --git a/plupload.module b/plupload.module index a37a62a..42ac5d0 100644 --- a/plupload.module +++ b/plupload.module @@ -220,6 +220,8 @@ function plupload_element_pre_render($element) { ); } + $settings['required'] = !empty($element['#required']); + if (empty($element['#description'])) { $element['#description'] = ''; }