registerAsset(); $this->registerJs(); return $this->renderInput(); } /** * 初始化 */ public function init() { parent::init(); if ($this->hasModel() && !isset($this->options['name'])) { $this->name = $this->options['name'] = Html::getInputName($this->model, $this->attribute); if ($this->type == 'checkbox') { $this->name .= "[]"; } } //表单默认会把css类form-control带过来,用来控制边框,这里不需边框所以去除 $this->options["class"] = str_replace("form-control", '', $this->options["class"]); $this->options["class"] = $this->options["class"] . ' icheck-label-group'; } /** * 注册js和css */ protected function registerAsset() { $view = $this->getView(); IcheckAsset::register($view); } /** * 注册js */ protected function registerJs() { $js = <<