function styles_ui_style_add_form_validate in Styles 7.2
Validation handler for the add style form.
File
- contrib/
styles_ui/ styles_ui.admin.inc, line 83 - Administrative page callbacks for the Styles UI module.
Code
function styles_ui_style_add_form_validate($form, $form_state) {
$field_type = $form_state['values']['field_type'];
$style_name = $form_state['values']['name'];
$styles = styles_default_styles();
if (!preg_match('!^[a-z0-9_]+$!', $style_name)) {
form_set_error('style_name', t('The machine-readable style name must contain only lowercase letters, numbers, and underscores.'));
}
else {
if (!empty($styles[$field_type]['styles'][$style_name])) {
form_set_error('style_name', t('The machine-readable style name %style_name is already taken.', array(
'%style_name' => $style_name,
)));
}
}
}