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: */
7:
8: namespace Nette\Forms\Controls;
9:
10: use Nette;
11:
12:
13: /**
14: * Check box control. Allows the user to select a true or false condition.
15: *
16: * @author David Grudl
17: */
18: class Checkbox extends BaseControl
19: {
20:
21: /**
22: * @param string label
23: */
24: public function __construct($label = NULL)
25: {
26: parent::__construct($label);
27: $this->control->type = 'checkbox';
28: $this->value = FALSE;
29: }
30:
31:
32: /**
33: * Sets control's value.
34: * @param bool
35: * @return self
36: */
37: public function setValue($value)
38: {
39: $this->value = is_scalar($value) ? (bool) $value : FALSE;
40: return $this;
41: }
42:
43:
44: /**
45: * Generates control's HTML element.
46: * @return Nette\Utils\Html
47: */
48: public function getControl()
49: {
50: return parent::getControl()->checked($this->value);
51: }
52:
53: }
54: