summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJelle Sebreghts2012-05-09 09:41:05 (GMT)
committerJelle Sebreghts2012-05-09 09:41:05 (GMT)
commit0a039588a8ccda2e5ac9c52c8546f850f336bcee (patch)
tree3d024aaf221a4fc5bd7d91719817610cf2d8d18c
parent8573fbeb044fa2deabe4d7d1201203283bb1fc45 (diff)
Issue #1559618 by Akshita: Added Is there a way to set the no of files to be uploaded?.
-rw-r--r--multifile.inc12
1 files changed, 12 insertions, 0 deletions
diff --git a/multifile.inc b/multifile.inc
index 41bbf99..3ae1e30 100644
--- a/multifile.inc
+++ b/multifile.inc
@@ -21,6 +21,7 @@ function _webform_defaults_multifile() {
'addextensions' => '',
'size' => 800,
),
+ 'max_amount' => -1,
'scheme' => 'public',
'directory' => '',
'progress_indicator' => 'throbber',
@@ -59,6 +60,16 @@ function _webform_edit_multifile($component) {
$form['#theme'] = 'webform_edit_multifile';
$form['#element_validate'] = array('_webform_edit_multifile_check_directory');
$form['#after_build'] = array('_webform_edit_multifile_check_directory');
+ $options[-1] = t('Unlimited');
+ $options += drupal_map_assoc(range(1, 10));
+ $form['validation']['max_amount'] = array(
+ '#title' => t('File limit'),
+ '#description' => t('The number of files the user is allowed to upload per submission with this component.'),
+ '#type' => 'select',
+ '#options' => $options,
+ '#default_value' => $component['extra']['max_amount'],
+ '#parents' => array('extra', 'max_amount'),
+ );
$form['validation']['filtering'] = array(
'#element_validate' => array('_webform_edit_multifile_filtering_validate'),
@@ -354,6 +365,7 @@ function _webform_render_multifile($component, $value = NULL, $filter = TRUE) {
// Stores all the settings for each field in an array so the javascript files can load later
" if (typeof MultiFile_fields == 'undefined') {MultiFile_fields = []} \n".
" MultiFile_fields.push(\n {\n id :'$id',\n properties : {\n".
+ " max:" . $component['extra']['max_amount'] . ",\n" .
" accept:'" . join('|', $current_types) . "',\n STRING: {\n".
" remove:'" . t('Remove') . "',\n".
" denied:'" . t('You are kindly asked not to submit !ext files in this form.', array('!ext' => '$ext')) . "',\n".