alexantr / yii2-colorpicker
适用于Yii 2的颜色选择器输入小部件
2.0.0
2018-02-09 14:08 UTC
Requires
- yiisoft/yii2: ~2.0.6
This package is auto-updated.
Last update: 2024-09-23 15:00:04 UTC
README
此扩展可以渲染一个带有 jQuery MiniColors 的输入。
注意:1.x 版本使用 jscolor Color Picker
安装
通过 composer 安装扩展
composer require alexantr/yii2-colorpicker
使用方法
以下代码在视图文件中会渲染一个带有颜色选择器的输入
<?= alexantr\colorpicker\ColorPicker::widget(['name' => 'attributeName']) ?>
如果您想在ActiveForm中使用此输入小部件,可以这样做
<?= $form->field($model, 'attributeName')->widget(alexantr\colorpicker\ColorPicker::className()) ?>
应使用 clientOptions
属性来配置 jQuery MiniColors
<?= alexantr\colorpicker\ColorPicker::widget([ 'name' => 'attributeName', 'clientOptions' => [ 'control' => 'wheel', 'letterCase' => 'uppercase', 'theme' => 'default', // the widget uses 'bootstrap' theme ], ]) ?>