source: trunk/Packages/FormManager/Types/Boolean.php

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: 877 bytes
Line 
1<?php
2
3include_once(dirname(__FILE__).'/Base.php');
4
5class TypeBoolean extends TypeBase
6{
7 function __construct(FormManager $FormManager)
8 {
9 parent::__construct($FormManager);
10 $this->DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=');
11 }
12
13 function OnView(array $Item): ?string
14 {
15 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';
16 return '<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'/>';
17 }
18
19 function OnEdit(array $Item): string
20 {
21 if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';
22 return '<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'/>';
23 }
24
25 function OnLoad(array $Item): ?string
26 {
27 if (array_key_exists($Item['Name'], $_POST)) return 1;
28 else return 0;
29 }
30
31 function OnCanLoad(array $Item): bool
32 {
33 return true;
34 }
35}
Note: See TracBrowser for help on using the repository browser.