diff --git a/console/controllers/TestController.php b/console/controllers/TestController.php index 3919bd6..5e95ebf 100644 --- a/console/controllers/TestController.php +++ b/console/controllers/TestController.php @@ -17,11 +17,11 @@ class TestController extends Controller { //Yii::$aa->security->generateRandomString(8); $security = Yii::createObject("yii\base\Security"); $n = 0; - for ($i = 1; $i < 100000; $i++) { + for ($i = 1; $i < 1000; $i++) { //$key = $security->generateRandomString(8); $key = rand(10000000, 99999999); - /*$key = strtolower($key); - $key = str_replace(['_', '-'], 'a', $key);*/ + //$key = strtolower($key); + //$key = str_replace(['_', '-'], 'a', $key); $ret[$key] += 1; } diff --git a/kcadmin/views/category/_form.php b/kcadmin/views/category/_form.php index ef30344..bd61a56 100644 --- a/kcadmin/views/category/_form.php +++ b/kcadmin/views/category/_form.php @@ -5,6 +5,7 @@ use yii\widgets\ActiveForm; use blobt\widgets\DatePicker; use blobt\widgets\Select2; use blobt\widgets\DatetimePicker; +use blobt\widgets\Icheck; /* @var $this yii\web\View */ /* @var $model common\models\Category */ @@ -15,14 +16,14 @@ use blobt\widgets\DatetimePicker;
- + field($model, 'cat_name')->textInput(['maxlength' => true]) ?> field($model, 'icon')->textInput(['maxlength' => true]) ?> field($model, 'icon_type')->widget(Select2::className(), ["data" => $model::$iconType]) ?> - - field($model, 'icon_type')->checkbox(["a" => "A", "b" => "B"]) ?> + + field($model, 'icon_type')->widget(Icheck::className(), ["items" => ["a" => "A", "b" => "B"]]) ?> field($model, 'description')->textarea(['rows' => 6]) ?> diff --git a/vendor/blobt/web/DatetimepickBootstrapAsset.php b/vendor/blobt/web/DatetimepickBootstrapAsset.php index cc56447..cb6664e 100644 --- a/vendor/blobt/web/DatetimepickBootstrapAsset.php +++ b/vendor/blobt/web/DatetimepickBootstrapAsset.php @@ -41,7 +41,7 @@ class DatetimepickBootstrapAsset extends AssetBundle { ]; public $js = [ 'js/bootstrap-datetimepicker.min.js', - 'js/locales/bootstrap-datepicker.zh-CN.min.js', + 'js/locales/bootstrap-datetimepicker.zh-CN.js', ]; public $depends = [//所有依赖 'yii\web\JqueryAsset', diff --git a/vendor/blobt/widgets/Icheck.php b/vendor/blobt/widgets/Icheck.php new file mode 100644 index 0000000..7695bb8 --- /dev/null +++ b/vendor/blobt/widgets/Icheck.php @@ -0,0 +1,100 @@ +registerAsset(); + $this->registerJs(); + return $this->renderCheckBox(); + } + + /** + * 初始化 + */ + public function init() { + parent::init(); + if ($this->hasModel() && !isset($options['name'])) { + $this->name = $this->options['name'] = Html::getInputName($this->model, $this->attribute); + } + if (count($this->items) > 1) { + $this->name .="[]"; + } + } + + /** + * 注册js和css + */ + protected function registerAsset() { + $view = $this->getView(); + IcheckAsset::register($view); + } + + /** + * 注册js + */ + protected function registerJs() { + $js = <<