Namespaces

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

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