You are here

function fivestar_color_form_validate in Fivestar 6.2

Same name and namespace in other branches
  1. 5 fivestar_color.inc \fivestar_color_form_validate()
  2. 6 fivestar_color.inc \fivestar_color_form_validate()

Validate handler for color form.

1 string reference to 'fivestar_color_form_validate'
fivestar_settings in includes/fivestar.admin.inc
Callback function for admin/settings/fivestar. Display the settings form.

File

includes/fivestar.color.inc, line 200
File containing functions relating to the color widget.

Code

function fivestar_color_form_validate($form, &$form_state) {
  if ($form_state['values']['fivestar_color_type'] == 'default' || $_POST['fivestar_color_type'] == '') {
    $form_state['values']['fivestar_color_type'] = 'default';
    return;
  }
  foreach ($form_state['values']['fivestar_colors'] as $key => $value) {
    $form_state['values']['fivestar_colors'][$key] = trim(drupal_strtolower($value));
    if (!preg_match('/^#([0-9a-f]{3}|[0-9a-f]{6})$/', $form_state['values']['fivestar_colors'][$key]) && !($key == 'matte' && ($value == 'none' || $value == ''))) {
      form_set_error('fivestar_colors][' . $key, t('The entered value %color is not a valid hex color.', array(
        '%color' => $value,
      )));
    }
  }
}