You are here

function QuantChartChartAPI::adminSettingsValidate in Quant 7

Implements parent::adminSettingsValidate().

Overrides QuantChart::adminSettingsValidate

File

plugins/QuantChartChartAPI.inc, line 55

Class

QuantChartChartAPI
QuantChart plugin class to generate charts using chart.module (Chart API)

Code

function adminSettingsValidate(&$form, &$form_state) {

  // Iterate through colors
  $colors = array();

  // Store all colors in a single array
  for ($i = 0; $i < QUANT_PALETTE_AMOUNT; $i++) {
    $color = $form_state['values']['quant_chartapi_palette_color_' . $i];
    $colors[] = strtoupper($color);

    // Remove form value to avoid multiple color variables
    unset($form_state['values']['quant_chartapi_palette_color_' . $i]);
  }

  // Make sure we at least have one color
  if (empty($colors)) {
    form_set_error('color', t('You need to enter at least one color.'));
  }
  else {

    // Save colors in a single variable
    $form_state['values']['quant_chartapi_palette'] = $colors;
  }
}