Author: David Grudl
Inheritance: extends BaseControl
 /**
  * @param User $sender
  * @param array $usersByRestrictions
  * @param bool $multi
  * @return MultiSelectBox|SelectBox
  */
 public function create(User $sender, array $usersByRestrictions, $multi = false)
 {
     $recipients = $this->prepareRecipients($sender, $usersByRestrictions);
     $selectBox = null;
     if ($multi === true) {
         $selectBox = new MultiSelectBox('Příjemci', $recipients);
     } else {
         $selectBox = new SelectBox('Příjemce', $recipients);
     }
     $selectBox->setAttribute('size', 13);
     $selectBox->setRequired('Vyberte příjemce.');
     return $selectBox;
 }
Example #2
0
 /**
  * @param IControlConfig $config
  * @return NULL|Controls\ChoiceControl
  */
 public function createControl(IControlConfig $config)
 {
     $control = NULL;
     if ($config->getType() === IControlConfig::RADIO_LIST) {
         $control = new Controls\RadioList($config->getLabel());
     } elseif ($config->getType() === IControlConfig::SELECT) {
         $control = new Controls\SelectBox($config->getLabel());
         $control->setPrompt($config->getOption(IControlConfig::PROMPT) ?: FALSE);
     }
     // Setup items
     if ($control && ($items = $this->helper->processItems($control, $config)) !== NULL) {
         $control->setItems($items);
     }
     return $control;
 }
Example #3
0
 public function getControl()
 {
     $control = parent::getControl();
     $control->{'data-linkedelement'} = $this->linkedElement;
     $control->{'data-linkedproperty'} = $this->linkedProperty;
     return $control;
 }
Example #4
0
 /**
  * Generates control's HTML element.
  * @return Html
  */
 public function getControl()
 {
     $items = $this->getPrompt() === FALSE ? array() : array('' => $this->translate($this->getPrompt()));
     $translated = array();
     foreach ($this->items as $key => $value) {
         $translated[$key] = $this->translate($value);
     }
     asort($translated);
     return Helpers::createSelectBox($items + $translated, array('selected?' => $this->value, 'disabled:' => is_array($this->disabled) ? $this->disabled : NULL))->addAttributes(parent::getControl()->attrs);
 }
 /**
  * We have to repeat that method in our class due to parent::$options property accesibility
  *  Otherwise we would be working with BaseControl::$options
  * @param array   $items   [description]
  * @param boolean $useKeys [description]
  */
 public function setItems(array $items, $useKeys = TRUE)
 {
     if (!$useKeys) {
         $res = array();
         foreach ($items as $key => $value) {
             unset($items[$key]);
             if (is_array($value)) {
                 foreach ($value as $val) {
                     $res[$key][(string) $val] = $val;
                 }
             } else {
                 $res[(string) $value] = $value;
             }
         }
         $items = $res;
     }
     $this->options = $items;
     return parent::setItems(Nette\Utils\Arrays::flatten($items, TRUE));
 }
Example #6
0
 /**
  * Adds select box control that allows single item selection.
  * @param  string  control name
  * @param  string  label
  * @param  array   items from which to choose
  * @param  int     number of rows that should be visible
  * @return Nette\Forms\Controls\SelectBox
  */
 public function addSelect($name, $label = NULL, array $items = NULL, $size = NULL)
 {
     $control = new Controls\SelectBox($label, $items);
     if ($size > 1) {
         $control->setAttribute('size', (int) $size);
     }
     return $this[$name] = $control;
 }
 /**
  * Sets items from which to choose.
  * @param  array
  * @param  bool
  * @return self
  */
 public function setItems(array $items, $useKeys = TRUE)
 {
     parent::setItems($items, $useKeys);
     if ($this->tempValue != NULL) {
         parent::setValue($this->tempValue);
     }
 }
Example #8
0
 /**
  * Generates control's HTML element.
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     return parent::getControl()->multiple(TRUE);
 }
 /**
  * Generates control's HTML element
  *
  * @return \Nette\Utils\Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->class = 'imageselectbox';
     return $control;
 }
 /**
  * Sets items from which to choose.
  * @param  array
  * @return DependentSelectBox  provides a fluent interface
  */
 public function setItems(array $items, $useKeys = TRUE)
 {
     if (!$useKeys) {
         throw new NotSupportedException("Working without keys not supported !");
     }
     return parent::setItems($items, $useKeys);
 }
Example #11
0
 function getControl()
 {
     $control = parent::getControl();
     $control->multiple = TRUE;
     return $control;
 }
Example #12
0
parent::getHtmlName().'[]';}function
getControl(){$control=parent::getControl();$control->multiple=TRUE;return$control;}static
Example #13
0
 /**
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     if ($this->forceDisabled) {
         $this::setDisabled(TRUE);
     }
     return parent::getControl();
 }
 public function loadHttpData()
 {
     if (!$this->multiple) {
         parent::loadHttpData();
         return;
     }
     $this->value = array_keys(array_flip($this->getHttpData(\Nette\Forms\Form::DATA_TEXT)));
     if (is_array($this->disabled)) {
         $this->value = array_diff($this->value, array_keys($this->disabled));
     }
 }