function styles_ui_preset_add_form_validate in Styles 7
Same name and namespace in other branches
- 6.2 contrib/styles_ui/includes/styles_ui.admin.inc \styles_ui_preset_add_form_validate()
- 6 contrib/styles_ui/includes/styles_ui.admin.inc \styles_ui_preset_add_form_validate()
Validation handler for the add style preset form.
File
- contrib/
styles_ui/ styles_ui.admin.inc, line 75 - Administrative page callbacks for the Styles UI module.
Code
function styles_ui_preset_add_form_validate($form, $form_state) {
$field_type = $form_state['values']['field_type'];
$preset_name = $form_state['values']['preset_name'];
$presets = styles_presets();
if (!preg_match('!^[a-z0-9_]+$!', $preset_name)) {
form_set_error('preset_name', t('The machine-readable style preset name must contain only lowercase letters, numbers, and underscores.'));
}
else {
if (!empty($presets[$field_type][$preset_name])) {
form_set_error('preset_name', t('The machine-readable style preset name %preset_name is already taken.', array(
'%preset_name' => $preset_name,
)));
}
}
}