Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationLatte
      • ApplicationTracy
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsLatte
      • Framework
      • HttpTracy
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Templating
    • Utils
  • NetteModule
  • none
  • Tracy

Classes

  • BaseControl
  • Button
  • Checkbox
  • CheckboxList
  • ChoiceControl
  • CsrfProtection
  • HiddenField
  • ImageButton
  • MultiChoiceControl
  • MultiSelectBox
  • RadioList
  • SelectBox
  • SubmitButton
  • TextArea
  • TextBase
  • TextInput
  • UploadControl
  • Overview
  • Namespace
  • 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 (https://davidgrudl.com)
  6:  */
  7: 
  8: namespace Nette\Forms\Controls;
  9: 
 10: use Nette;
 11: use Nette\Utils\Html;
 12: 
 13: 
 14: /**
 15:  * Set of checkboxes.
 16:  *
 17:  * @author     David Grudl
 18:  *
 19:  * @property-read Html $separatorPrototype
 20:  */
 21: class CheckboxList extends MultiChoiceControl
 22: {
 23:     /** @var Html  separator element template */
 24:     protected $separator;
 25: 
 26: 
 27:     public function __construct($label = NULL, array $items = NULL)
 28:     {
 29:         parent::__construct($label, $items);
 30:         $this->control->type = 'checkbox';
 31:         $this->separator = Html::el('br');
 32:     }
 33: 
 34: 
 35:     /**
 36:      * Generates control's HTML element.
 37:      * @return string
 38:      */
 39:     public function getControl()
 40:     {
 41:         $items = $this->getItems();
 42:         reset($items);
 43:         $input = parent::getControl();
 44:         return Nette\Forms\Helpers::createInputList(
 45:             $this->translate($items),
 46:             array_merge($input->attrs, array(
 47:                 'id' => NULL,
 48:                 'checked?' => $this->value,
 49:                 'disabled:' => $this->disabled,
 50:                 'required' => NULL,
 51:                 'data-nette-rules:' => array(key($items) => $input->attrs['data-nette-rules']),
 52:             )),
 53:             $this->label->attrs,
 54:             $this->separator
 55:         );
 56:     }
 57: 
 58: 
 59:     /**
 60:      * Generates label's HTML element.
 61:      * @param  string
 62:      * @return Html
 63:      */
 64:     public function getLabel($caption = NULL)
 65:     {
 66:         return parent::getLabel($caption)->for(NULL);
 67:     }
 68: 
 69: 
 70:     /**
 71:      * Returns separator HTML element template.
 72:      * @return Html
 73:      */
 74:     public function getSeparatorPrototype()
 75:     {
 76:         return $this->separator;
 77:     }
 78: 
 79: 
 80:     /**
 81:      * @return Html
 82:      */
 83:     public function getControlPart($key)
 84:     {
 85:         $key = key(array((string) $key => NULL));
 86:         return parent::getControl()->addAttributes(array(
 87:             'id' => $this->getHtmlId() . '-' . $key,
 88:             'checked' => in_array($key, (array) $this->value, TRUE),
 89:             'disabled' => is_array($this->disabled) ? isset($this->disabled[$key]) : $this->disabled,
 90:             'required' => NULL,
 91:             'value' => $key,
 92:         ));
 93:     }
 94: 
 95: 
 96:     /**
 97:      * @return Html
 98:      */
 99:     public function getLabelPart($key)
100:     {
101:         return parent::getLabel($this->items[$key])->for($this->getHtmlId() . '-' . $key);
102:     }
103: 
104: }
105: 
Nette 2.2 API documentation generated by ApiGen 2.8.0