Yii 1.1: minicolors-colorpicker

Yii extension for the miniColors jQuery color chooser plugin
8 followers

Simple wrapper extension for the simple and excellent miniColors jQuery color picker plugin

Requirements

Yii 1.1 or above (I assume - built with Yii 1.1.8)

Usage

Extract / checkout these files into the SMiniColors directory under protected/extensions in your Yii project

This extension contains two classes:

SColorPicker Widget

Generates a standard HTML input tag with the ID you specify

$this->widget('ext.SMiniColors.SColorPicker', array(
    'id' => 'myInputId',
    'defaultValue'=>'#000000',
    'hidden'=>false, // defaults to false - can be set to hide the textarea with the hex
    'options' => array(), // jQuery plugin options
    'htmlOptions' => array(), // html attributes
));

SActiveColorPicker Widget

Generates an "Active" HTML input for the CActiveRecord model you specify

$this->widget('ext.SMiniColors.SActiveColorPicker', array(
    'model' => $model,
    'attribute' => 'myModelAttribute',
    'hidden'=>false, // defaults to false - can be set to hide the textarea with the hex
    'options' => array(), // jQuery plugin options
    'htmlOptions' => array(), // html attributes
));

Resources

Total 9 comments

#15502 report it
yatskanich.sasha at 2013/11/15 05:05pm
Super

Thanks for this nice extension

#14985 report it
Rajith R at 2013/09/26 06:15am
@thaddeusmt

Thanks for the good ext.

#6435 report it
thaddeusmt at 2012/01/10 11:25am
Fix the .svn issues

I removed the version control folders - I think they actually came with the jQuery plugin! Anyway the .zip is clean now. Thanks!

#5615 report it
ianaré at 2011/10/25 09:31am
SVN

Thank you for this nice extension, it works better and is smaller than some others I've tried.

One minor annoyance : the zip file has .svn folders in it (in the "source" folder), this conflicts with my own subversion settings.

#5580 report it
thaddeusmt at 2011/10/21 11:43am
oops, thanks Clem

Had the wrong documentation for the SActiveColorPicker picker. Fixed now! Thanks

#5579 report it
Clem at 2011/10/21 11:29am
Example for SActiveColorPicker
$this->widget('ext.SMiniColors.SActiveColorPicker', array(
    'model' => $model,
    'attribute' => 'color_attribute',
    'hidden'=>false, // defaults to false - can be set to hide the textarea with the hex
    'options' => array(), // jQuery plugin options
    'htmlOptions' => array(), // html attributes
));
#5472 report it
Raoul at 2011/10/14 01:22pm
you're welcome !

;)

#5458 report it
thaddeusmt at 2011/10/13 09:18pm
Hidden field option added

Thanks for the tip Raoul, an easy and handy improvement! It's in the 0.2 release now. Cheers

#5447 report it
Raoul at 2011/10/12 03:50pm
nice but ...

Thanks for this nice extension thaddeusmt.

I played a little with it but could get it to attach the color picker icon to a hidden input. To support hidden fields, here is a small modification of your extension.

First, add public member to both ColorPicker classes

public $hidden=false;

Second replace the run() code with :

SColorPicker:

echo ($this->hidden == false ? 
        CHtml::textField($this->getId(), $this->defaultValue, $this->htmlOptions)
      : CHtml::hiddenField($this->getId(), $this->defaultValue, $this->htmlOptions));

SActiveColorPicker:

echo ($this->hidden == false ?
        CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions)
    : CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions));

This is very simple modification, and (tada) : hidden field are available ! ciao

Leave a comment

Please to leave your comment.

Create extension