function calendar_validate_hex_color in Calendar 7.3
Same name and namespace in other branches
- 5.2 calendar.module \calendar_validate_hex_color()
- 6.2 calendar.module \calendar_validate_hex_color()
- 7 calendar.module \calendar_validate_hex_color()
- 7.2 calendar.module \calendar_validate_hex_color()
Check to make sure the user has entered a valid 6 digit hex color.
1 string reference to 'calendar_validate_hex_color'
- calendar_plugin_row::options_form in includes/
calendar_plugin_row.inc - Provide a form for setting options.
File
- ./
calendar.module, line 544 - Adds calendar filtering and displays to Views.
Code
function calendar_validate_hex_color($element, &$form_state) {
if (!$element['#required'] && empty($element['#value'])) {
return;
}
if (!preg_match('/^#(?:(?:[a-f\\d]{3}){1,2})$/i', $element['#value'])) {
form_error($element, t("'@color' is not a valid hex color", array(
'@color' => $element['#value'],
)));
}
else {
form_set_value($element, $element['#value'], $form_state);
}
}