Ejemplo n.º 1
0
 /**
  * Renders the filter content
  * @return string
  */
 public function render()
 {
     $defaults = ['class' => 'form-control'];
     if ($this->multiple) {
         $defaults['multiple'] = 'multiple';
     } else {
         $defaults['prompt'] = \Yii::t('admin/gridview', 'All');
     }
     $options = array_merge($defaults, $this->options);
     return Select2::widget(['bootstrap' => true, 'model' => $this->getModel(), 'attribute' => $this->getAttribute(), 'items' => $this->values, 'options' => $options]) . $this->getError();
 }
Ejemplo n.º 2
0
 /**
  * Renders Select2 widget using https://github.com/vova07/yii2-select2-widget
  * If this extension is not installed,simple dropdown control will be shown instead
  * @link https://github.com/vova07/yii2-select2-widget
  * @param $items
  * @param $options
  * @return static
  */
 public function select2($items, $options = [])
 {
     $settings = ArrayHelper::remove($options, 'settings', []);
     if (class_exists('vova07\\select2\\Widget')) {
         $defaultSettings = ['width' => '100%'];
         $defaultOptions = ['class' => 'form-control'];
         $settings = ArrayHelper::merge($defaultSettings, $settings);
         $options = ArrayHelper::merge($defaultOptions, $options);
         return $this->widget(Select2::className(), ['bootstrap' => true, 'items' => $items, 'options' => $options, 'settings' => $settings]);
     }
     return $this->dropDownList($items, $options);
 }
Ejemplo n.º 3
0
 /**
  * Renders the filter content
  * @return string
  */
 public function render()
 {
     $options = array_merge(['prompt' => '', 'class' => 'form-control'], $this->options);
     return Select2::widget(['bootstrap' => true, 'model' => $this->column->grid->filterModel, 'attribute' => $this->column->attribute, 'items' => ArrayHelper::merge(['' => ''], $this->values), 'options' => $options]) . $this->getError();
 }