First of all I would like to thank Pestaa an his patience for help me in #yii channel. I’m very new in Yii and in OOP in general, so you know it can be frustating 
Now the problem and how I’ve (Pestaa, better) solved. The guy who designed “backgrounds” table decided to store background color in RGB decimal format, comma separated, like “255,204,204”. Very smart guy, uh? 
It was impossible to ask to my customer to change background value manually, using a input type text, so I decided to use a very nice JQuery plugin, called ColorPicker: http://www.eyecon.ro/colorpicker/
Better way to use that plugin is to use rgb in hex format, like "ffcccc".
I had first to convert decimal comma separated values in hex format, then change hex value using ColorPicker and then store in table in decimal comma separated again. I’ve tried to put logic in view but it wasn’t a good solution.
An important thing that I’ve learned is “getter function”. A getter function is a model function like getFoo() that you can recall in your view using $model->foo. Another thing I’ve learned is that a getter function doesn’t need parameter (as I was trying to do
). So public function getFoo(){} in model and $model->foo (and not $model->foo() in the view).
I needed also a function to convert from hex to dec and from dec to hex.
So:
/**
* @return converted hex. Example: from 255,204,204 to ffcccc
*/
public function colorHex($colors){
$dec = explode(',',$colors);
$r = dechex($dec[0]);
$g = dechex($dec[1]);
$b = dechex($dec[2]);
$rgb = $r.$g.$b;
return $rgb;
}
/**
* @return converted dec. Example: from ffcccc to 255,204,204
*/
public function colorDec($colors){
$dec = hexdec(substr($colors,0,2)).",".hexdec(substr($colors,2,2)).",".hexdec(substr($colors,4,2));
return $dec;
}
/**
* now, the getter functions
* background_color is the field where bg values are stored
*/
public function getHexBackground(){
return $this->colorHex($this->background_color);
}
// this getter function return decimal values using colorDec one
public function getDecBackground(){
return $this->colorDec($this->background_color);
}
/**
* to store corrected value I use decBackground function in beforeValidate method
*/
public function beforeValidate(){
$this->background_color = $this->decBackground;
}
Please correct me if I’ve done something wrong, but it seems it works like a charms
)
[EDIT] Of course in the view I use $model->hexBackground to display correct hex values