Output Color Code as Hex in 5.7 Block View

Permalink
I am working on a block for 5.7 that uses the "hex" format for color codes as a hex (ex. #000000), instead of the RGB format.

The picker works just fine, but only renders in the RGB format. Is there a way to output the color code in hex format in the block view?

PineCreativeLabs
 
MrKDilkington replied on at Permalink Best Answer Reply
MrKDilkington
Hi growthcurve,

You can change the preferred format in the options array.

http://bgrins.github.io/spectrum/#options-preferredFormat...

Example:
$color = Core::make('helper/form/color');
$color->output('colorValue', $colorValue, array('preferredFormat'=>'hex'));
PineCreativeLabs replied on at Permalink Reply
PineCreativeLabs
That's exactly what I was looking for! Works perfect!

Also, you can set a custom default color by doing this:

$color->output('colorValue', $colorValue?$colorValue:"#00adef", array('preferredFormat'=>'hex'));