Packages

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • none

Classes

  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
 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 NCheckbox extends NFormControl
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 NHtml
46:      */
47:     public function getControl()
48:     {
49:         return parent::getControl()->checked($this->value);
50:     }
51: 
52: }
53: 
Nette Framework 2.0.18 (for PHP 5.2, prefixed) API documentation generated by ApiGen 2.8.0