コード例 #1
0
ファイル: DataSelect.php プロジェクト: tekkla/core-html
 /**
  * Builds and returns html code
  *
  * @see \Core\Html\Form\Select::build()
  */
 public function build()
 {
     foreach ($this->datasource as $index => $val) {
         $option = $this->createOption();
         // inner will always be used
         $option->setInner($val);
         $option->setValue($this->index_is_value ? $index : $val);
         // in dependence of the data type is value to be selected $val or $inner
         if (!empty($this->selected)) {
             // A list of selected?
             if (is_array($this->selected)) {
                 if (array_search($this->index_is_value ? $index : $val, $this->selected)) {
                     $option->isSelected(1);
                 }
             } else {
                 if ($this->selected == ($this->index_is_value ? $index : $val)) {
                     $option->isSelected(1);
                 }
             }
         }
     }
     return parent::build();
 }
コード例 #2
0
ファイル: OnOffSwitch.php プロジェクト: tekkla/core-html
 /**
  *
  * {@inheritdoc}
  *
  * @see \Core\Html\Form\Select::build()
  */
 public function build()
 {
     $this->createSwitches();
     /* @var $option \Core\Html\Form\Option */
     foreach ($this->switch as $option) {
         $value = $option->getValue();
         if (!$value) {
             $value = $option->getInner();
         }
         if ($this->state == $value) {
             $option->isSelected();
         }
         $this->addOption($option);
     }
     return parent::build();
 }