You are here

function colors_admin_type_settings_submit in Colors 7

Form submission handler for colors_generate_settings_form().

1 string reference to 'colors_admin_type_settings_submit'
colors_generate_settings_form in includes/colors.admin.inc
Generate an admin form for each Colors plugin.

File

includes/colors.admin.inc, line 238
Color page callbacks for the Colors module.

Code

function colors_admin_type_settings_submit($form, &$form_state) {
  if (empty($form['#colors_type']) || empty($form['#colors_info'])) {
    return;
  }
  $type = $form['#colors_type'];
  $info = $form['#colors_info'];
  $multiple = !empty($info['multiple_function']);
  $repeat = !empty($multiple) ? $info['multiple_function']() : array(
    NULL => NULL,
  );
  $multiple_enabled = FALSE;
  foreach ($repeat as $id => $repeat_value) {
    $enabled_type = !empty($multiple) ? $type . '_' . $id : $type;
    $enabled_string = 'colors_' . $enabled_type . '_enabled';
    variable_set($enabled_string, (bool) $form_state['values'][$enabled_string]);
    if (!empty($form_state['values'][$enabled_string])) {
      $multiple_enabled = TRUE;
    }
    foreach ($info['function']($id) as $key => $value) {
      $class = 'colors_' . $type . '_' . $key;
      _colors_set_colors($class, $type, $form_state['values'][$class]);
    }
  }
  if ($multiple && $multiple_enabled) {
    variable_set('colors_' . $type . '_enabled', TRUE);
  }
  colors_css_clear();
  drupal_set_message(t('The configuration options have been saved.'));
}