Changeset 871 for trunk/Common/Form/Form.php
- Timestamp:
- Apr 6, 2020, 9:19:50 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Form/Form.php
r747 r871 43 43 function LoadDefaults() 44 44 { 45 foreach($this->Definition['Items'] as $Index => $Item) 46 if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 47 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 48 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 49 { 50 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) 51 $this->Values[$Index] = $Item['Default']; 45 foreach ($this->Definition['Items'] as $Index => $Item) 46 { 47 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 48 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 49 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 50 { 51 if (!array_key_exists($Index, $this->Values)) 52 $this->Values[$Index] = $Item['Default']; 53 } 52 54 } 53 55 } … … 128 130 'Rows' => array(), 129 131 ); 130 if ($Context != '') $Context = $Context.'-';131 foreach ($this->Definition['Items'] as $Index => $Item)132 { 133 if (!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false;134 if($Item['ReadOnly'] == false)135 if(!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))136 if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or137 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and138 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne')))139 {132 if ($Context != '') $Context = $Context.'-'; 133 foreach ($this->Definition['Items'] as $Index => $Item) 134 { 135 if (!array_key_exists('ReadOnly', $Item)) $Item['ReadOnly'] = false; 136 if ($Item['ReadOnly'] == false) 137 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false)) 138 if (!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 139 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 140 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 141 { 140 142 $Parameters = array('Value' => $this->Values[$Index], 'Name' => $Index, 141 142 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];143 'Type' => $Item['Type'], 'Values' => $this->Values); 144 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null']; 143 145 else unset($Parameters['Null']); 144 if (array_key_exists('OnPreset', $Item)) $Parameters['OnPreset'] = $Item['OnPreset'];146 if (array_key_exists('OnPreset', $Item)) $Parameters['OnPreset'] = $Item['OnPreset']; 145 147 else unset($Parameters['OnPreset']); 146 148 147 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes))148 { 149 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))149 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 150 { 151 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 150 152 $this->FormManager->Type->RegisterType($Item['Type'], '', 151 153 $this->FormManager->FormTypes[$Item['Type']]); 152 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference')154 if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 153 155 { 154 156 $UseType = 'OneToMany'; 155 } else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration')157 } else if ($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 156 158 $UseType = 'Enumeration'; 157 159 } else $UseType = $Item['Type']; 158 160 $Edit = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnEdit', $Parameters); 159 if(array_key_exists('Suffix', $Item)) $Edit .= $Item['Suffix']; 160 161 $Caption = $Item['Caption'].':'; 162 if(array_key_exists($Index, $this->ValuesValidate) and 163 $this->ValuesValidate[$Index]) { 161 if (array_key_exists('Suffix', $Item)) $Edit .= $Item['Suffix']; 162 163 $Caption = $Item['Caption'].':'; 164 if (array_key_exists($Index, $this->ValuesValidate) and 165 $this->ValuesValidate[$Index]) 166 { 164 167 $Format = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'GetValidationFormat', array()); 165 if ($Format != '') $Caption .= '<br/><small>'.$Format.'</small>';168 if ($Format != '') $Caption .= '<br/><small>'.$Format.'</small>'; 166 169 $Caption = '<span style="color:red;">'.$Caption.'</span>'; 167 170 } 168 if(!$this->FormManager->Type->IsHidden($UseType))171 if (!$this->FormManager->Type->IsHidden($UseType)) 169 172 array_push($Table['Rows'], array($Caption, $Edit)); 170 else $Hidden .= $Edit;171 }173 else $Hidden .= $Edit; 174 } 172 175 } 173 176 $Output = '<fieldset><legend>'.$this->Definition['Title'].'</legend>'.Table($Table). 174 177 $Hidden.'</fieldset>'; 175 return ($Output);178 return $Output; 176 179 } 177 180 … … 270 273 function LoadValuesFromFormBlock($Context = '') 271 274 { 272 if ($Context != '') $Context = $Context.'-';275 if ($Context != '') $Context = $Context.'-'; 273 276 $Values = array(); 277 foreach ($this->Definition['Items'] as $Index => $Item) 278 { 279 if (!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false)) 280 { 281 if ((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 282 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 283 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and 284 (!array_key_exists('ReadOnly', $Item) or 285 (array_key_exists('ReadOnly', $Item) and 286 ($Item['ReadOnly'] != true)))) 287 { 288 //if (array_key_exists($Context.$Index, $_POST)) 289 if (array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 290 { 291 if (!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 292 $this->FormManager->Type->RegisterType($Item['Type'], '', 293 $this->FormManager->FormTypes[$Item['Type']]); 294 $CustomType = $this->FormManager->FormTypes[$Item['Type']]['Type']; 295 if ($CustomType == 'Reference') 296 $UseType = 'OneToMany'; 297 else if ($CustomType == 'Enumeration') 298 $UseType = 'Enumeration'; 299 } else $UseType = $Item['Type']; 300 $Parameters = array('Name' => $Index, 'Type' => $Item['Type'], 'Values' => $this->Values); 301 if (array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null']; 302 else unset($Parameters['Null']); 303 $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoad', 304 $Parameters); 305 } 306 } else 307 { 308 if (isset($Item['Default'])) { 309 if (isset($Item['Null']) and ($Item['Null'] == true)) 310 $Values[$Index] = null; 311 else $Values[$Index] = $Item['Default']; 312 } 313 } 314 } 315 return($Values); 316 } 317 318 function Validate() 319 { 320 $Valid = true; 274 321 foreach($this->Definition['Items'] as $Index => $Item) 275 if(!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false))276 {277 322 if((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 278 323 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and … … 294 339 $UseType = 'Enumeration'; 295 340 } else $UseType = $Item['Type']; 296 $Parameters = array('Name' => $Index, 'Type' => $Item['Type'], 'Values' => $this->Values);297 if(array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null'];298 else unset($Parameters['Null']);299 $Values[$Index] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnLoad',300 $Parameters);301 }302 } else303 {304 if(isset($Item['Default'])) {305 if(isset($Item['Null']) and ($Item['Null'] == true))306 $Values[$Index] = null;307 else $Values[$Index] = $Item['Default'];308 }309 }310 return($Values);311 }312 313 function Validate()314 {315 $Valid = true;316 foreach($this->Definition['Items'] as $Index => $Item)317 if((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or318 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and319 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and320 (!array_key_exists('ReadOnly', $Item) or321 (array_key_exists('ReadOnly', $Item) and322 ($Item['ReadOnly'] != true))))323 {324 //if(array_key_exists($Context.$Index, $_POST))325 if(array_key_exists($Item['Type'], $this->FormManager->FormTypes))326 {327 if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList))328 $this->FormManager->Type->RegisterType($Item['Type'], '',329 $this->FormManager->FormTypes[$Item['Type']]);330 $CustomType = $this->FormManager->FormTypes[$Item['Type']]['Type'];331 if($CustomType == 'Reference')332 $UseType = 'OneToMany';333 else if($CustomType == 'Enumeration')334 $UseType = 'Enumeration';335 } else $UseType = $Item['Type'];336 341 337 342 $Parameters = array('Value' => $this->Values[$Index]);
Note:
See TracChangeset
for help on using the changeset viewer.