function skinr_ui_form_validate in Skinr 6.2
Same name and namespace in other branches
- 7.2 skinr_ui.edit.inc \skinr_ui_form_validate()
Validation handler.
1 string reference to 'skinr_ui_form_validate'
- skinr_ui_form_alter in ./
skinr_ui.module - Implementation of hook_form_alter().
File
- ./
skinr_ui.module, line 574
Code
function skinr_ui_form_validate(&$form, &$form_state) {
$form_id = $form_state['values']['form_id'];
$skinr_config = skinr_fetch_config();
$error = FALSE;
foreach ($skinr_config as $module => $settings) {
if (isset($settings['form'][$form_id]) && isset($form_state['values']['skinr_settings'][$module . '_group'])) {
foreach ($form_state['values']['skinr_settings'][$module . '_group'] as $theme_name => $theme) {
if (isset($theme['_additional'])) {
$form_settings = array_merge(_skinr_fetch_config_defaults('form'), $settings['form'][$form_id]);
// Validate additional classes field.
if (preg_match('/[^a-zA-Z0-9\\-\\_\\s]/', $theme['_additional'])) {
form_set_error('skinr_settings][' . $module . '_group][' . $theme_name . '][_additional', t('Additional classes for Skinr may only contain alphanumeric characters, spaces, - and _.'));
$error = TRUE;
}
// Keep looping, there might be other modules that implement the same form_id.
}
}
}
}
// Undo any grouping to ease processing on submit.
if (!$error) {
$info = skinr_skin_data();
foreach ($skinr_config as $module => $settings) {
if (isset($settings['form'][$form_id]) && isset($form_state['values']['skinr_settings'][$module . '_group'])) {
foreach ($form_state['values']['skinr_settings'][$module . '_group'] as $theme_name => $theme) {
if (empty($info[$theme_name]->options['groups'])) {
continue;
}
foreach ($info[$theme_name]->options['groups'] as $group_name => $group) {
if (!empty($theme['widgets'][$group_name]) && is_array($theme['widgets'][$group_name])) {
$group_values = $theme['widgets'][$group_name];
unset($form_state['values']['skinr_settings'][$module . '_group'][$theme_name]['widgets'][$group_name]);
$form_state['values']['skinr_settings'][$module . '_group'][$theme_name]['widgets'] = array_merge($form_state['values']['skinr_settings'][$module . '_group'][$theme_name]['widgets'], $group_values);
}
}
}
}
}
}
}