From 6bdc883ab674b2651adc3d4c4040de766e31ad1a Mon Sep 17 00:00:00 2001
From: blobt <380255922@qq.com>
Date: Fri, 13 Sep 2019 18:47:29 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dselect2=E8=BE=B9=E6=A1=86?=
=?UTF-8?q?=E4=B8=8D=E5=8F=98=E8=89=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
common/models/Category.php | 2 +-
kcadmin/views/category/_form.php | 6 ++----
kcadmin/web/css/site.css | 11 +++++++++++
vendor/blobt/web/IcheckAsset.php | 3 +++
vendor/blobt/widgets/Icheck.php | 14 ++++++++------
vendor/blobt/widgets/Select2.php | 13 +++++++++++--
6 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/common/models/Category.php b/common/models/Category.php
index 888501c..3dcc1e2 100644
--- a/common/models/Category.php
+++ b/common/models/Category.php
@@ -39,7 +39,7 @@ class Category extends \yii\db\ActiveRecord {
*/
public function rules() {
return [
- [['cat_name'], 'required'],
+ [['icon_type','cat_name','created_at'], 'required'],
[['icon_type', 'sort_order', 'created_at', 'updated_at'], 'integer'],
[['description'], 'string'],
[['cat_name', 'icon'], 'string', 'max' => 64],
diff --git a/kcadmin/views/category/_form.php b/kcadmin/views/category/_form.php
index bd61a56..422a8ea 100644
--- a/kcadmin/views/category/_form.php
+++ b/kcadmin/views/category/_form.php
@@ -11,8 +11,6 @@ use blobt\widgets\Icheck;
/* @var $model common\models\Category */
/* @var $form yii\widgets\ActiveForm */
?>
-
-
@@ -21,9 +19,9 @@ use blobt\widgets\Icheck;
= $form->field($model, 'icon')->textInput(['maxlength' => true]) ?>
- = $form->field($model, 'icon_type')->widget(Select2::className(), ["data" => $model::$iconType]) ?>
+ = $form->field($model, 'icon_type')->widget(Select2::className(), ["items" => $model::$iconType]) ?>
- = $form->field($model, 'icon_type')->widget(Icheck::className(), ["items" => ["a" => "A", "b" => "B"]]) ?>
+ field($model, 'icon_type')->widget(Icheck::className(), ["items" => ["a" => "Option A", "b" => "Option B", "c" => "Option C"]]) ?>
= $form->field($model, 'description')->textarea(['rows' => 6]) ?>
diff --git a/kcadmin/web/css/site.css b/kcadmin/web/css/site.css
index 83a29a0..966d765 100644
--- a/kcadmin/web/css/site.css
+++ b/kcadmin/web/css/site.css
@@ -30,4 +30,15 @@
.login-form h6 {
text-align: center;
+}
+
+/*修复select2插件 from表框颜色不生效*/
+.form-group.has-error .select2-selection, .form-group.has-error .select2-selection {
+ border-color: #dd4b39;
+ box-shadow: none;
+}
+
+.form-group.has-success .select2-selection, .form-group.has-success .select2-selection {
+ border-color: #00a65a;
+ box-shadow: none;
}
\ No newline at end of file
diff --git a/vendor/blobt/web/IcheckAsset.php b/vendor/blobt/web/IcheckAsset.php
index 6d72c00..743e93d 100644
--- a/vendor/blobt/web/IcheckAsset.php
+++ b/vendor/blobt/web/IcheckAsset.php
@@ -44,5 +44,8 @@ class IcheckAsset extends AssetBundle {
public $js = [
'icheck.min.js'
];
+ public $depends = [
+ 'yii\web\JqueryAsset'
+ ];
}
diff --git a/vendor/blobt/widgets/Icheck.php b/vendor/blobt/widgets/Icheck.php
index 7695bb8..0bad81f 100644
--- a/vendor/blobt/widgets/Icheck.php
+++ b/vendor/blobt/widgets/Icheck.php
@@ -66,9 +66,6 @@ class Icheck extends InputWidget {
if ($this->hasModel() && !isset($options['name'])) {
$this->name = $this->options['name'] = Html::getInputName($this->model, $this->attribute);
}
- if (count($this->items) > 1) {
- $this->name .="[]";
- }
}
/**
@@ -84,7 +81,10 @@ class Icheck extends InputWidget {
*/
protected function registerJs() {
$js = <<