setItems() public method

Sets options and option groups from which to choose.
public setItems ( array $items, $useKeys = TRUE ) : self
$items array
return self
コード例 #1
0
 /**
  * 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));
 }
コード例 #2
0
 /**
  * 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);
     }
 }
コード例 #3
0
 /**
  * Sets options
  *
  * @return self
  */
 public function setItems(array $items, $useKeys = TRUE)
 {
     $imageItems = $this->getImageItems($items);
     return parent::setItems(Arrays::flatten($imageItems, TRUE));
 }
コード例 #4
0
 /**
  * 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);
 }
コード例 #5
0
 /**
  * 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) {
         if ($this->multiple) {
             $this->setMultipleValue($this->tempValue);
         } else {
             parent::setValue($this->tempValue);
         }
     }
 }