Esempio n. 1
0
 /**
  * Import options from array
  *
  * @param array $options
  * @return SelectOptionGroup
  */
 public function importOptions(array $options = [])
 {
     foreach ($options as $option) {
         $value = isset($option['value']) ? $option['value'] : null;
         $title = isset($option['title']) ? $option['title'] : $option['value'];
         $selected = isset($option['selected']) ? true : false;
         $this->addOption(SelectOption::forge()->setOptionParams($value, $title, $selected));
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * Import options from array
  *
  * @param array $options
  *
  * @return Select
  */
 public function importOptions(array $options = [])
 {
     foreach ($options as $option) {
         if (isset($option['options']) && is_array($option['options'])) {
             $label = isset($option['label']) ? $option['label'] : null;
             $groupOptions = !empty($option['options']) ? $option['options'] : [];
             $this->addGroup(SelectOptionGroup::forge()->setTitle($label)->importOptions($groupOptions));
         } else {
             $value = isset($option['value']) ? $option['value'] : null;
             $title = isset($option['title']) ? $option['title'] : $option['value'];
             $selected = isset($option['selected']) ? true : false;
             $this->addOption(SelectOption::forge()->setOptionParams($value, $title, $selected));
         }
     }
     return $this;
 }