zgb7mtr / yii2-bootstrap-color-picker
Bootstrap Colorpicker widget for Yii2.
Installs: 3 873
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 3
Open Issues: 0
Type:yii2-extension
Requires
- bower-asset/bootstrap-colorpicker: ~2.5
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-10-14 19:35:29 UTC
README
Renders a Bootstrap ColorPicker plugin.
Installation
The preferred way to install this extension is through composer.
Either run
composer require zgb7mtr/yii2-bootstrap-color-picker:~1.0
or add
"zgb7mtr/yii2-bootstrap-color-picker" : "~1.0"
to the require section of your application's composer.json
file.
Usage
This widget renders a Bootstrap ColorPicker input control. Best suitable for model with date string attribute.
Example of use with a form
There are two ways of using it, with an ActiveForm
instance or as a widget setting up its model
and attribute
.
<?php
use zgb7mtr\colorPicker\ColorPicker;
// as a widget
?>
<?= ColorPicker::widget([
'model' => $model,
'attribute' => 'color',
]);?>
<?php
// with an ActiveForm instance
?>
<?= $form->field($model, 'color')->widget(
ColorPicker::className());?>
Example of use without a model
<?php
use zgb7mtr\colorPicker\ColorPicker;
?>
<?= ColorPicker::widget([
'name' => 'Test',
'value' => '#CCCCCC'
]);?>