You are here

function colorfield_picker_element_process in Colorfield 7

Define the color picker with Javascript popup element processing. Add popup attributes to $element.

1 string reference to 'colorfield_picker_element_process'
colorfield_element_info in ./colorfield.module
Implements hook_element_info().

File

./colorfield.module, line 79
A simple color field module with a color picker.

Code

function colorfield_picker_element_process($element, &$form_state, $form) {
  $element['colorfield_picker'] = array(
    '#type' => 'textfield',
    '#size' => 7,
    '#maxlength' => 7,
    '#default_value' => isset($element['#default_value']['colorfield_picker']) ? $element['#default_value']['colorfield_picker'] : NULL,
    '#attributes' => array(
      'class' => array(
        'colorfield-colorpicker',
      ),
    ),
    '#attached' => array(
      'library' => array(
        array(
          'system',
          'farbtastic',
        ),
      ),
      'js' => array(
        drupal_get_path('module', 'colorfield') . '/js/colorfield-farbtastic.js',
      ),
    ),
    '#suffix' => '<div class="colorfield-picker"></div>',
  );
  return $element;
}