1 color.module color_get_color_element($theme_name, $color_name, &$form)

Creates the render array for a color element.

The function also stores a list of which color elements have already been generated, so that the color module does not attempt to print out color settings twice.

@since 1.12.2

Parameters

string $theme_name: The theme to get color settings from.

string $color_name: The name of the color element to return.

array $form: The form array for the theme settings form.

Return value

array: The render array for the color element.

File

core/modules/color/color.module, line 145
Allows users to change the color scheme of themes.

Code

function color_get_color_element($theme_name, $color_name, &$form) {
  // Get the color settings from the theme.
  $theme_info = color_get_info($theme_name);
  $palette = color_get_palette($theme_name);

  // Remember that the element has already been placed.
  $form['#color_elements'][] = $color_name;

  // Return the render array for the color element.
  return array(
    '#type' => 'color',
    '#title' => check_plain($theme_info['fields'][$color_name]),
    '#value_callback' => 'color_palette_color_value',
    '#default_value' => $palette[$color_name],
    '#size' => 8,
    '#parents' => array('palette', $color_name),
    '#attributes' => array(
      'data-color-name' => $color_name,
    ),
  );
}