function skinr_ui_form_validate in Skinr 7.2
Same name and namespace in other branches
- 6.2 skinr_ui.module \skinr_ui_form_validate()
Form validation handler for skinr_ui_form_alter().
1 string reference to 'skinr_ui_form_validate'
- skinr_ui_form in ./
skinr_ui.edit.inc - Form builder for the skins configuration form.
File
- ./
skinr_ui.edit.inc, line 288 - Page callbacks for the Skinr UI module related to editing skins.
Code
function skinr_ui_form_validate($form, &$form_state) {
$module = $form_state['values']['module'];
$element = $form_state['values']['element'];
$error = FALSE;
if (isset($form_state['values']['skinr_settings'])) {
foreach ($form_state['values']['skinr_settings'] as $theme_name => $theme) {
if (isset($theme['groups']['_additional']['_additional'])) {
// Validate additional classes field.
if (preg_match('/[^a-zA-Z0-9\\-\\_\\s]/', $theme['groups']['_additional']['_additional'])) {
form_set_error('skinr_settings][' . $theme_name . '][groups][_additional][_additional', t('Additional classes for Skinr may only contain alphanumeric characters, spaces, - and _.'));
$error = TRUE;
}
}
}
}
if (!$error) {
$groups = skinr_get_group_info();
// Add hard-coded additional classes group.
$groups['_additional'] = array(
'title' => 'Additional',
'description' => 'Additional custom classes.',
'weight' => 0,
);
if (!empty($form_state['values']['skinr_settings'])) {
foreach ($form_state['values']['skinr_settings'] as $theme_name => $theme) {
// Unset active tab variables.
foreach ($theme['groups'] as $skin_name => $options) {
if (strpos($skin_name, '__groups__active_tab') !== FALSE) {
unset($form_state['values']['skinr_settings'][$theme_name]['groups'][$skin_name]);
continue;
}
}
// Undo any grouping to ease processing on submit.
foreach ($groups as $group_name => $group) {
if (!empty($theme['groups'][$group_name]) && is_array($theme['groups'][$group_name])) {
$group_values = $theme['groups'][$group_name];
unset($form_state['values']['skinr_settings'][$theme_name]['groups'][$group_name]);
$form_state['values']['skinr_settings'][$theme_name] = array_merge($form_state['values']['skinr_settings'][$theme_name], $group_values);
}
}
unset($form_state['values']['skinr_settings'][$theme_name]['groups']);
}
}
}
}