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