Last change
on this file was 8, checked in by chronos, 19 months ago |
- Modified: Updated Common package.
- Modified: Form types made as separate FormManager package.
- Fixed: PHP 8.1 support.
|
File size:
1.3 KB
|
Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/Base.php');
|
---|
4 |
|
---|
5 | class TypeEnumeration extends TypeBase
|
---|
6 | {
|
---|
7 | function OnView($Item): ?string
|
---|
8 | {
|
---|
9 | $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']);
|
---|
10 | if (array_key_exists($Item['Value'], $Type['Parameters']['States']))
|
---|
11 | $Output = $Type['Parameters']['States'][$Item['Value']];
|
---|
12 | else $Output = $Item['Value'];
|
---|
13 | return $Output;
|
---|
14 | }
|
---|
15 |
|
---|
16 | function OnEdit(array $Item): string
|
---|
17 | {
|
---|
18 | $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']);
|
---|
19 | $Output = '<select name="'.$Item['Name'].'">';
|
---|
20 | if (array_key_exists('Null', $Item) and $Item['Null'])
|
---|
21 | {
|
---|
22 | if ($Item['Value'] == NULL) $Selected = ' selected="1"'; else $Selected = '';
|
---|
23 | $Output .= '<option value=""'.$Selected.'></option>';
|
---|
24 | }
|
---|
25 | foreach ($Type['Parameters']['States'] as $Index => $StateName)
|
---|
26 | {
|
---|
27 | if ($Item['Value'] == $Index) $Selected = ' selected="1"'; else $Selected = '';
|
---|
28 | $Output .= '<option value="'.$Index.'"'.$Selected.'>'.$StateName.'</option>';
|
---|
29 | }
|
---|
30 | $Output .= '</select>';
|
---|
31 | return $Output;
|
---|
32 | }
|
---|
33 |
|
---|
34 | function OnLoad(array $Item): ?string
|
---|
35 | {
|
---|
36 | if ($_POST[$Item['Name']] == '') return NULL;
|
---|
37 | return $_POST[$Item['Name']];
|
---|
38 | }
|
---|
39 |
|
---|
40 | function OnLoadDb(array $Item): ?string
|
---|
41 | {
|
---|
42 | if ($Item['Value'] == '') return NULL;
|
---|
43 | else return $Item['Value'];
|
---|
44 | }
|
---|
45 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.