registerAsset(); $this->registerSelect2Js(); return $this->renderSelect(); } /** * 初始化 */ public function init() { parent::init(); if ($this->hasModel() && !isset($this->options['name'])) { $this->name = $this->options['name'] = Html::getInputName($this->model, $this->attribute); } if (!empty($this->promptText)) { $this->options = ArrayHelper::merge($this->options, ['prompt' => $this->promptText]); } } /** * 注册js和css */ protected function registerAsset() { $view = $this->getView(); Select2Asset::register($view); } /** * 注册js */ protected function registerSelect2Js() { $js = <<