1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
6: * @package Nette\Forms\Controls
7: */
8:
9:
10:
11: /**
12: * Check box control. Allows the user to select a true or false condition.
13: *
14: * @author David Grudl
15: * @package Nette\Forms\Controls
16: */
17: class Checkbox extends FormControl
18: {
19:
20: /**
21: * @param string label
22: */
23: public function __construct($label = NULL)
24: {
25: parent::__construct($label);
26: $this->control->type = 'checkbox';
27: $this->value = FALSE;
28: }
29:
30:
31: /**
32: * Sets control's value.
33: * @param bool
34: * @return self
35: */
36: public function setValue($value)
37: {
38: $this->value = is_scalar($value) ? (bool) $value : FALSE;
39: return $this;
40: }
41:
42:
43: /**
44: * Generates control's HTML element.
45: * @return Html
46: */
47: public function getControl()
48: {
49: return parent::getControl()->checked($this->value);
50: }
51:
52: }
53: