Fixed bug #1104: Setting file fields in TCA to "required" makes it impossible to...
authorOliver Hader <oliver.hader@typo3.org>
Sat, 6 Mar 2010 00:19:04 +0000 (00:19 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Sat, 6 Mar 2010 00:19:04 +0000 (00:19 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/branches/TYPO3_4-2@7083 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_tceforms.php
typo3/jsfunc.tbe_editor.js

index d7dd5c8..227c6bb 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-03-06  Oliver Hader  <oliver@typo3.org>
+
+       * Fixed bug #1104: Setting file fields in TCA to "required" makes it impossible to save the record (thanks to Ingmar Schlecht & Tobias Liebig)
+
 2010-03-04  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #13057: htmlArea RTE sometimes deletes contents
index db36978..d78e7ff 100755 (executable)
@@ -2080,7 +2080,9 @@ class t3lib_TCEforms      {
 
                                if(!$disabled && !(isset($config['disable_controls']) && t3lib_div::inList($config['disable_controls'], 'upload'))) {
                                                // Adding the upload field:
-                                       if ($this->edit_docModuleUpload)        $item.='<input type="file" name="'.$PA['itemFormElName_file'].'"'.$this->formWidth().' size="60" />';
+                                       if ($this->edit_docModuleUpload) {
+                                               $item.='<input type="file" name="'.$PA['itemFormElName_file'].'"'.$this->formWidth().' size="60" onchange="' . implode('', $PA['fieldChangeFunc']) . '" />';
+                                       }
                                }
                        break;
                        case 'folder':  // If the element is of the internal type "folder":
index 03d3234..a74acf3 100755 (executable)
@@ -213,8 +213,18 @@ var TBE_EDITOR = {
                                        if (tempObj && Element.hasClassName(tempObj, 'inlineRecord')) {
                                                form = tempObj.value ? tempObj.value.split(',') : [];
                                        }
+
+                               } else {
+                                               // special treatment for file uploads
+                                       var tempObj = document[TBE_EDITOR.formname][elementName.replace(/^data/, 'data_files')];
+                                       var numberOfElements = form.length;
+
+                                       if (tempObj && tempObj.type == 'file' && tempObj.value) {
+                                               numberOfElements++; // Add new uploaded file to the number of elements
+                                       }
                                }
-                               if (!TBE_EDITOR.checkRange(form, elementData.range[0], elementData.range[1])) {
+
+                               if (!TBE_EDITOR.checkRange(numberOfElements, elementData.range[0], elementData.range[1])) {
                                        result = 0;
                                        if (autoNotify) {
                                                TBE_EDITOR.setImage('req_'+elementData.rangeImg, TBE_EDITOR.images.req);
@@ -432,8 +442,13 @@ var TBE_EDITOR = {
                        return false;
                }
        },
-       checkRange: function(el,lower,upper) {
-               if (el && el.length>=lower && el.length<=upper) {
+       checkRange: function(numberOfElements, lower, upper) {
+                       // for backwards compatibility, check if we're dealing with an element as first parameter
+               if(typeof numberOfElements == 'object') {
+                       numberOfElements = numberOfElements.length;
+               }
+
+               if (numberOfElements >= lower && numberOfElements <= upper) {
                        return true;
                } else {
                        return false;