8.5.x color.module color_scheme_form($complete_form, FormStateInterface $form_state, $theme)
8.0.x color.module color_scheme_form($complete_form, FormStateInterface $form_state, $theme)
8.1.x color.module color_scheme_form($complete_form, FormStateInterface $form_state, $theme)
8.2.x color.module color_scheme_form($complete_form, FormStateInterface $form_state, $theme)
8.3.x color.module color_scheme_form($complete_form, FormStateInterface $form_state, $theme)
8.4.x color.module color_scheme_form($complete_form, FormStateInterface $form_state, $theme)
8.6.x color.module color_scheme_form($complete_form, FormStateInterface $form_state, $theme)
5.x color.module color_scheme_form($theme)
6.x color.module color_scheme_form(&$form_state, $theme)
7.x color.module color_scheme_form($complete_form, &$form_state, $theme)

Form callback. Returns the configuration form.

File

modules/color/color.module, line 150

Code

function color_scheme_form(&$form_state, $theme) {
  $base = drupal_get_path('module', 'color');
  $info = color_get_info($theme);

  // Add Farbtastic color picker
  drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE);
  drupal_add_js('misc/farbtastic/farbtastic.js');

  // Add custom CSS/JS
  drupal_add_css($base . '/color.css', 'module', 'all', FALSE);
  drupal_add_js($base . '/color.js');
  drupal_add_js(array(
    'color' => array(
      'reference' => color_get_palette($theme, true),
    ),
  ), 'setting');

  // See if we're using a predefined scheme
  $current = implode(',', variable_get('color_' . $theme . '_palette', array()));

  // Note: we use the original theme when the default scheme is chosen.
  $current = isset($info['schemes'][$current]) ? $current : ($current == '' ? reset($info['schemes']) : '');

  // Add scheme selector
  $info['schemes'][''] = t('Custom');
  $form['scheme'] = array(
    '#type' => 'select',
    '#title' => t('Color set'),
    '#options' => $info['schemes'],
    '#default_value' => $current,
  );

  // Add palette fields
  $palette = color_get_palette($theme);
  $names = array(
    'base' => t('Base color'),
    'link' => t('Link color'),
    'top' => t('Header top'),
    'bottom' => t('Header bottom'),
    'text' => t('Text color'),
  );
  $form['palette']['#tree'] = true;
  foreach ($palette as $name => $value) {
    $form['palette'][$name] = array(
      '#type' => 'textfield',
      '#title' => $names[$name],
      '#default_value' => $value,
      '#size' => 8,
    );
  }
  $form['theme'] = array(
    '#type' => 'value',
    '#value' => arg(4),
  );
  $form['info'] = array(
    '#type' => 'value',
    '#value' => $info,
  );
  return $form;
}