function styles_ui_preset_add_form_validate in Styles 6.2
Same name and namespace in other branches
- 6 contrib/styles_ui/includes/styles_ui.admin.inc \styles_ui_preset_add_form_validate()
- 7 contrib/styles_ui/styles_ui.admin.inc \styles_ui_preset_add_form_validate()
Validation handler for the add style preset form.
File
- contrib/
styles_ui/ includes/ styles_ui.admin.inc, line 69 - styles/contrib/styles_ui/includes/styles_ui.admin.inc 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,
)));
}
}
}