Color Picker Widget - How to Disable and Enable

Permalink
Anyone know how to disable and enable the Color Picker widget?

The only info I can find is at the sight that makes the underlying product:

http://bgrins.github.io/spectrum/...

The site describes a "disabled" flag but I can't figure out how they actually implement the toggle. And perhaps is won't work with the Concrete5 widget wrapper.

Most, if not all, of the Form widget input elements can be disable and enabled and it would be very helpful if the Color Picker could be too.

jfhencken
 
MrKDilkington replied on at Permalink Best Answer Reply
MrKDilkington
Hi jfhencken,

You can pass the disabled flag to the color picker using the optional third argument in the output() method. The third argument is used to add Spectrum color picker options.
https://documentation.concrete5.org/tutorials/how-to-use-the-color-p...

Example:
$color = Core::make('helper/form/color');
$color->output('myColorPicker', $myColorPicker, array('disabled' => true));

- This will load a disabled color picker.

To enable and disable the color picker, you can use the Spectrum "enable" and "disable" methods:
$("#ccm-colorpicker-myColorPicker").spectrum("enable");
$("#ccm-colorpicker-myColorPicker").spectrum("disable");

You can then enable or disable the color picker based on some condition.