Changeset 536 for trunk/Common/Form/Form.php
- Timestamp:
- May 18, 2013, 6:51:10 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Form/Form.php
r529 r536 9 9 var $Definition; 10 10 var $Values; 11 var $ValuesFilter; 11 12 var $OnSubmit; 12 13 var $Database; … … 18 19 $this->Definition = array(); 19 20 $this->Values = array(); 21 $this->ValuesFilter = array(); 20 22 $this->OnSubmit = ''; 21 23 } … … 49 51 $Edit = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnView', 50 52 array('Value' => $this->Values[$Index], 'Name' => $Index, 51 'Type' => $Item['Type'], 'Values' => $this->Values)); 53 'Type' => $Item['Type'], 'Values' => $this->Values, 54 'Filter' => $this->ValuesFilter[$Index])); 52 55 if(array_key_exists('Suffix', $Item)) $Edit .= ' '.$Item['Suffix']; 53 56 if(!$this->FormManager->Type->IsHidden($UseType)) … … 116 119 117 120 function LoadValuesFromDatabase($Id) 118 { 119 $DbResult = $this->Database->query('SELECT T.* FROM '.$this->Definition['Table'].' AS T WHERE T.Id='.$Id); 121 { 122 foreach($this->Definition['Items'] as $Index => $Item) 123 if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 124 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 125 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 126 { 127 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default']; 128 if(array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 129 { 130 if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 131 $this->FormManager->Type->RegisterType($Item['Type'], '', 132 $this->FormManager->FormTypes[$Item['Type']]); 133 if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Reference') 134 $UseType = 'OneToMany'; 135 else if($this->FormManager->FormTypes[$Item['Type']]['Type'] == 'Enumeration') 136 $UseType = 'Enumeration'; 137 } else $UseType = $Item['Type']; 138 $Columns[] = $this->FormManager->Type->ExecuteTypeEvent($UseType, 'OnFilterNameQuery', 139 array('Name' => $Index, 'Type' => $Item['Type'])); 140 } 141 $Columns = implode(',', $Columns); 142 $DbResult = $this->Database->query('SELECT '.$Columns.' FROM `'.$this->Definition['Table'].'` AS `T` WHERE `T`.`Id`='.$Id); 120 143 $DbRow = $DbResult->fetch_array(); 121 144 foreach($this->Definition['Items'] as $Index => $Item) … … 138 161 array('Value' => $DbRow[$Index], 'Name' => $Index, 139 162 'Type' => $Item['Type'], 'Values' => $this->Values)); 163 $this->ValuesFilter[$Index] = $DbRow[$Index.'_Filter']; 140 164 } 141 165 }
Note:
See TracChangeset
for help on using the changeset viewer.