/** * Generates select2 component [[Select2]]. * * @param array $items * @param array $options select2 options * @return $this */ public function select2($items, $options = []) { $this->parts['{input}'] = Select2::widget(array_merge($options, ['model' => $this->model, 'attribute' => $this->attribute, 'items' => $items, 'form' => $this->form, 'type' => $this->type, 'addon' => $this->addon])); $this->addon = []; // addon already processed by widget return $this; }
/** * Get default widget class based on input field type * @param string $type * @return string */ public static function getWidgetClassNameFromFieldType($type) { switch ($type) { case self::INPUT_COLOR: $widgetClass = BootstrapColorPicker::className(); break; case self::INPUT_MINI_COLORS: $widgetClass = MiniColors::className(); break; case self::INPUT_DATE: $widgetClass = DatePicker::className(); break; case self::INPUT_DATETIME: $widgetClass = DateTimePicker::className(); break; case self::INPUT_MULTISELECT: $widgetClass = MultiSelect::className(); break; case self::INPUT_SELECT2_MULTI: case self::INPUT_SELECT2_TAGS: case self::INPUT_SELECT2: $widgetClass = Select2::className(); break; case self::INPUT_SELECT_PICKER: case self::INPUT_SELECT_PICKER_MULTI: $widgetClass = BootstrapSelect::className(); break; case self::INPUT_SELECT_SPLITTER: $widgetClass = BootstrapSelectSplitter::className(); break; case self::INPUT_TIME: $widgetClass = TimePicker::className(); break; case self::INPUT_EDITOR_CK: $widgetClass = CKEditor::className(); break; case self::INPUT_EDITOR_BS_WYSIHTML5: $widgetClass = BootstrapWysihtml5::className(); break; case self::INPUT_EDITOR_BS_SUMMERNOTE: $widgetClass = BootstrapSummernote::className(); break; default: $widgetClass = ''; break; } return $widgetClass; }