This extension renders an input with jQuery MiniColors.
Note: Version 1.x uses jscolor Color Picker
Install extension through composer:
composer require alexantr/yii2-colorpicker
The following code in a view file would render an input with color picker:
<?= alexantr\colorpicker\ColorPicker::widget(['name' => 'attributeName']) ?>
If you want to use this input widget in an ActiveForm, it can be done like this:
<?= $form->field($model, 'attributeName')->widget(alexantr\colorpicker\ColorPicker::className()) ?>
Configuring the jQuery MiniColors should be done using the clientOptions
attribute:
<?= alexantr\colorpicker\ColorPicker::widget([
'name' => 'attributeName',
'clientOptions' => [
'control' => 'wheel',
'letterCase' => 'uppercase',
'theme' => 'default', // the widget uses 'bootstrap' theme
],
]) ?>