You are here

README.txt in Colorpicker 5

Same filename and directory in other branches
  1. 6.2 README.txt
  2. 6 README.txt
This module does nothing by itself but add a new form element type called a 'colorpicker'.  You can see an example useage in the colorpicker_example.module included in the package with this module, or use something similar to below.  

It also defines another element type called a 'colorpicker_textfield' which is associated to the 'colorpicker' by adding a property of '#colorpicker' and the '#id' of the colorpicker in question.  For an example of this, see the colorpicker_example.module.  Note that a default value (in hex) is necessary for this element type to work properly.

Also, if only one colorpicker type is defined on a page, all colorpicker_textfield's are associated with that colorpicker, regardless of the '#colorpicker' property.

$form['my_colorpicker'] = array(
  '#type' => 'colorpicker',
  '#title' => t('Color picker'),
  '#description' => t('Click in this textfield to start picking your color'),
);

$form['my_colorpicker_textfield'] = array(
  '#type' => 'colorpicker_textfield',
  '#title' => t('Color picker textfield'),
  '#description' => t('This is a textfield associated with the first Farbtastic color picker'),
  '#default_value' => variable_get('colorpicker_example_textfield', '#000000'),
  '#colorpicker' => 'my_colorpicker',
);

File

README.txt
View source
  1. This module does nothing by itself but add a new form element type called a 'colorpicker'. You can see an example useage in the colorpicker_example.module included in the package with this module, or use something similar to below.
  2. It also defines another element type called a 'colorpicker_textfield' which is associated to the 'colorpicker' by adding a property of '#colorpicker' and the '#id' of the colorpicker in question. For an example of this, see the colorpicker_example.module. Note that a default value (in hex) is necessary for this element type to work properly.
  3. Also, if only one colorpicker type is defined on a page, all colorpicker_textfield's are associated with that colorpicker, regardless of the '#colorpicker' property.
  4. $form['my_colorpicker'] = array(
  5. '#type' => 'colorpicker',
  6. '#title' => t('Color picker'),
  7. '#description' => t('Click in this textfield to start picking your color'),
  8. );
  9. $form['my_colorpicker_textfield'] = array(
  10. '#type' => 'colorpicker_textfield',
  11. '#title' => t('Color picker textfield'),
  12. '#description' => t('This is a textfield associated with the first Farbtastic color picker'),
  13. '#default_value' => variable_get('colorpicker_example_textfield', '#000000'),
  14. '#colorpicker' => 'my_colorpicker',
  15. );