function fivestar_color_form_validate in Fivestar 6
Same name and namespace in other branches
- 5 fivestar_color.inc \fivestar_color_form_validate()
- 6.2 includes/fivestar.color.inc \fivestar_color_form_validate()
Validate handler for color form.
1 string reference to 'fivestar_color_form_validate'
- fivestar_settings in ./
fivestar.module - Callback function for admin/settings/fivestar. Display the settings form.
File
- ./
fivestar_color.inc, line 157 - 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,
)));
}
}
}