Download & Extend

Using Colorpicker on a systems settings form

Project:Colorpicker
Version:5.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

The function for the system settings form is listed below:

function reztraq_admin_settings(){

$form['reztraq_colour'] = array(
'#type' => 'colorpicker',
'#title' => 'Colour Picker',
);

$form['free_colour_text_field'] = array(
'#type' => 'colorpicker_textfield',
'#title' => 'Free Colour',
'#colorpicker' => 'reztraq_colour',
'#default' => variable_get('free_colour_text_field','#0000ff'),
'#description' => t('Unbooked slots on the resource tracking view will be shaded with this colour.')
);

$form['booked_colour_text_field'] = array(
'#type' => 'colorpicker_textfield',
'#title' => 'Booked Colour',
'#colorpicker' => 'reztraq_colour',
'#default' => variable_get('booked_colour_text_field','#ff0000'),
'#description' => t('Booked slots on the resource tracking view will be shaded with this colour.')
);

return system_settings_form($form);

}

I have two issues:
1. The default values aren't being applied to the colorpicker_textfields.
2. After I click 'Save Configuration', I receive the following error message:
* '' is not a valid hex color
* '' is not a valid hex color

Looking at the code above, can you shed any light on this issue?

Many thanks
snarkcake

Comments

#1

Status:active» closed (fixed)

#default_value :)

#2

Yeah you beat me to it. Amazing how many mistakes in coding are simple typos that are SO hard to catch.

Dave

nobody click here