Reputation: 933
Is there any built in class or an extinction that makes the user pick color from something like this?
Upvotes: 1
Views: 6298
Reputation: 816
Now, you can simply use HTML5 color picker by setting the input type to color.
<?= $form->field($model, 'color_code')->textInput(['maxlength' => true,'type'=>'color']) ?>
Upvotes: 0
Reputation: 8146
You can simply render a color input like this with out using any plugins.
<?= $form->field($model, 'color', [
'template' => "{input}"
])->input('color',['class'=>"input_class"]) ?>
Upvotes: 5
Reputation: 3818
You can use kartik\widgets\ColorInput
widget. first install kartik\widgets\ColorInput
from this link
e.g. (Updated)
use kartik\widgets\ColorInput; or kartik\color\ColorInput;(for previous ver.)
<?php $form = ActiveForm::begin([
'id' => 'form',
]); ?>
<?= $form->field($model, 'color_code')->widget(ColorInput::classname(), ['options' => ['placeholder' => 'Select Color...'],]); ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-primary btn-create' : 'btn btn-info btn-create']) ?>
</div>
<?php ActiveForm::end(); ?>
Upvotes: 3