diff --git a/plupload.js b/plupload.js index f8be4d1..f03659b 100644 --- a/plupload.js +++ b/plupload.js @@ -60,8 +60,14 @@ Drupal.behaviors.plupload = { // 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 && !pluploadSettings.required) { + for (var attr in originalFormAttributes) { + $form.attr(attr, originalFormAttributes[attr]); + } + return; + } + if (uploader.files.length > 0 && uploader.total.uploaded == uploader.files.length) { // 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 diff --git a/plupload.module b/plupload.module index 9d55695..57d71b0 100644 --- a/plupload.module +++ b/plupload.module @@ -220,6 +220,8 @@ function plupload_element_pre_render($element) { ); } + $settings['required'] = $element['#required']; + if (empty($element['#description'])) { $element['#description'] = ''; }