Bug #17468 » 0005956_v4_trunk.patch

Administrator Admin, 2007-11-23 15:51

View differences:

t3lib/class.t3lib_tceforms.php (Arbeitskopie)
289 289
	var $palettesRendered=array();				// During rendering of forms this will keep track of which palettes has already been rendered (so they are not rendered twice by mistake)
290 290
	var $hiddenFieldListArr = array();			// This array of fields will be set as hidden-fields instead of rendered normally! For instance palette fields edited in the top frame are set as hidden fields since the main form has to submit the values. The top frame actually just sets the value in the main form!
291 291
	var $requiredFields=array();				// Used to register input-field names, which are required. (Done during rendering of the fields). This information is then used later when the JavaScript is made.
292
	var $requiredAdditional=array();			// Used to register input-field names, which are required an have additional requirements (e.g. like a date/time must be positive integer). The information of this array is merged with $this->requiredFields later.
292 293
	var $requiredElements=array();				// Used to register the min and max number of elements for selectorboxes where that apply (in the "group" type for instance)
293 294
	var $renderDepth=0;							// Keeps track of the rendering depth of nested records.
294 295
	var $savedSchemes=array();					// Color scheme buffer.
......
1071 1072
		$size = t3lib_div::intInRange($config['size']?$config['size']:30,5,$this->maxInputWidth);
1072 1073
		$evalList = t3lib_div::trimExplode(',',$config['eval'],1);
1073 1074

  
1074

  
1075 1075
		if($this->renderReadonly || $config['readOnly'])  {
1076 1076
			$itemFormElValue = $PA['itemFormElValue'];
1077 1077
			if (in_array('date',$evalList))	{
......
1093 1093
			switch ($func) {
1094 1094
				case 'required':
1095 1095
					$this->requiredFields[$table.'_'.$row['uid'].'_'.$field]=$PA['itemFormElName'];
1096
						// Mark this field for date/time disposal:
1097
					if (array_intersect($evalList, array('date', 'datetime', 'time'))) {
1098
						 $this->requiredAdditional[$PA['itemFormElName']]['isPositiveNumber'] = true;
1099
					}
1096 1100
					break;
1097 1101
				default:
1098 1102
					if (substr($func, 0, 3) == 'tx_')	{
......
4820 4824
				$field = $match[2];
4821 4825
				$elements[$record][$field]['required'] = 1;
4822 4826
				$elements[$record][$field]['requiredImg'] = $itemImgName;
4827
				if (isset($this->requiredAdditional[$itemName]) && is_array($this->requiredAdditional[$itemName])) {
4828
					$elements[$record][$field]['additional'] = $this->requiredAdditional[$itemName];
4829
				}
4823 4830
			}
4824 4831
		}
4825 4832
			// range:
t3lib/jsfunc.evalfield.js (Arbeitskopie)
80 80
	var theEvalType = this.split(evallist, ",", index);
81 81
	var newValue=value;
82 82
	while (theEvalType) {
83
		newValue = evalFunc.output(theEvalType, value, FObj);
83
		if (theEvalType != 'required') {
84
			newValue = evalFunc.output(theEvalType, value, FObj);
85
		}
84 86
		index++;
85 87
		theEvalType = this.split(evallist, ",", index);
86 88
	}
typo3/jsfunc.tbe_editor.js (Arbeitskopie)
44 44
					'requiredImg':	''
45 45
				}
46 46
			}
47
		
48 47
		},
49 48
	*/
50
	
49

  
51 50
	elements: {},
52 51
	recentUpdatedElements: {},
53 52
	actionChecks: { submit:	[] },
54
	
53

  
55 54
	formname: '',
56 55
	formnameUENC: '',
57 56
	loadTime: 0,
......
62 61
	prependFormFieldNames: 'data',
63 62
	prependFormFieldNamesUENC: 'data',
64 63
	prependFormFieldNamesCnt: 0,
65
	
64

  
66 65
	isPalettedoc: null,
67 66
	doSaveFieldName: 0,
68
	
67

  
69 68
	labels: {},
70 69
	images: {
71 70
		req: new Image(),
......
87 86
	getElement: function(record, field, type) {
88 87
		var result = null;
89 88
		var element;
90
		
89

  
91 90
		if (TBE_EDITOR.elements && TBE_EDITOR.elements[record] && TBE_EDITOR.elements[record][field]) {
92 91
			element = TBE_EDITOR.elements[record][field];
93 92
			if (type) {
......
96 95
				result = element;
97 96
			}
98 97
		}
99
		
98

  
100 99
		return result;
101 100
	},
102 101
	checkElements: function(type, recentUpdated, record, field) {
......
111 110
				if (elementData) {
112 111
					if (!TBE_EDITOR.checkElementByType(type, elementName, elementData)) result = 0;
113 112
				}
114
				
113

  
115 114
			} else {
116 115
				var elementFieldList, elRecIndex, elRecCnt, elFldIndex, elFldCnt;
117 116
				var elementRecordList = $H(source).keys();
......
129 128
				}
130 129
			}
131 130
		}
132
		
131

  
133 132
		return result;
134 133
	},
135 134
	checkElementByType: function(type, elementName, elementData) {
136 135
		var result = 1;
137
		
136

  
138 137
		if (type) {
139 138
			if (type == 'required') {
140
				if (!document[TBE_EDITOR.formname][elementName].value) {
139
				var value = document[TBE_EDITOR.formname][elementName].value;
140
				if (!value || elementData.additional && elementData.additional.isPositiveNumber && (isNaN(value) || Number(value) <= 0)) {
141 141
					result = 0;
142 142
					TBE_EDITOR.setImage('req_'+elementData.requiredImg, TBE_EDITOR.images.req);
143 143
				}
......
156 156
				}
157 157
			}
158 158
		}
159
		
159

  
160 160
		return result;
161 161
	},
162 162
	addActionChecks: function(type, checks) {
163 163
		TBE_EDITOR.actionChecks[type].push(checks);
164 164
	},
165
	
165

  
166 166
	// Regular TCEforms JSbottom scripts:
167 167
	loginRefreshed: function() {
168 168
		var date = new Date();
......
224 224
				TBE_EDITOR.setImage(imgReqObjName,TBE_EDITOR.images.req);
225 225
			}
226 226
		}
227
		
227

  
228 228
		if (TBE_EDITOR.isPalettedoc) { TBE_EDITOR.setOriginalFormFieldValue(theField) };
229 229
	},
230 230
	setOriginalFormFieldValue: function(theField) {
......
274 274
		if (!TBE_EDITOR.checkElements('required', false)) { OK = 0; }
275 275
		// $reqRangeCheck
276 276
		if (!TBE_EDITOR.checkElements('range', false)) { OK = 0; }
277
				
277

  
278 278
		if (OK || sendAlert==-1) {
279 279
			return true;
280 280
		} else {
(5-5/5)