This module extends the Forms API by adding a "color_picker" type field for use in custom forms. The element allows you to specify a list of hex colors that the user can choose from and the selection is stored as the field value.

It's usage is as follows:

    $form['bg_colour'] = [
      '#type' => 'color_picker',
      '#title' => t('Background Color'),
      '#description' => t('Select the background color.'),
      '#default_value' => '#000000',
      '#color_values' => '#000000,#ff0000,#00ff00,#0000ff,#ffffff',
    ];

Project information

Releases