1 <?php
2 /**
3 * CheckboxInput.php
4 *
5 * @author Elvyrra SAS
6 * @license http://rem.mit-license.org/ MIT
7 */
8
9 namespace Hawk;
10
11 /**
12 * This class describes checkboxes
13 *
14 * @package Form\Input
15 */
16 class CheckboxInput extends FormInput{
17
18 const TYPE = "checkbox";
19
20 /**
21 * Display the checkbox
22 *
23 * @return string The displayed HTML
24 */
25 public function display(){
26 if($this->value) {
27 $this->checked = true;
28 }
29 return parent::display();
30 }
31
32
33 /**
34 * Return the value of the input, formatted for MySQL database
35 *
36 * @return integer - if the checkbox has been submitted as checked, returns 1, else return 0
37 */
38 public function dbvalue(){
39 return $this->value ? 1 : 0;
40 }
41 }
42