Example #1
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     if ($this->inline && !isset($this->containerOptions['id'])) {
         $this->containerOptions['id'] = $this->options['id'] . '-container';
     } else {
         Html::addCssClass($this->options, 'form-control form-control-inline');
     }
 }
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     $this->options['multiple'] = true;
     if ($this->disabled) {
         $this->options['disabled'] = true;
     }
     Html::addCssClass($this->options, 'multi-select');
 }
Example #3
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     Html::addCssClass($this->options, 'form-control');
     if ($this->multiple) {
         $this->options['multiple'] = 'multiple';
     }
     if ($this->disabled) {
         $this->options['disabled'] = true;
     }
 }
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     $items = [];
     if ($this->hasModel()) {
         $this->_checked = array_map('trim', explode(',', $this->model->{$this->attribute}));
         foreach ($this->items as $item) {
             $input = [];
             if (is_string($item)) {
                 $input['name'] = $item;
                 $input['label'] = $this->model->getAttributeLabel($item);
             } else {
                 if (!isset($item['name'])) {
                     throw new InvalidConfigException('Option "name" is required.');
                 }
                 $input['name'] = $item['name'];
                 $input['label'] = isset($item['label']) ? $item['label'] : $this->model->getAttributeLabel($item['name']);
             }
             $items[] = $input;
         }
     } else {
         $this->_checked = array_map('trim', explode(',', $this->value));
         foreach ($this->items as $item) {
             $input = [];
             if (is_string($item)) {
                 $input['name'] = $item;
                 $input['label'] = Inflector::camel2words($item);
             } else {
                 if (!isset($item['name'])) {
                     throw new InvalidConfigException('Option "name" is required.');
                 }
                 $input['name'] = $item['name'];
                 $input['label'] = isset($item['label']) ? $item['label'] : Inflector::camel2words($item['name']);
             }
             $items[] = $input;
         }
     }
     $this->items = $items;
 }