You are here

function skinr_form_validate in Skinr 6

Validation handler.

1 string reference to 'skinr_form_validate'
skinr_form_alter in ./skinr.module
Implementation of hook_form_alter().

File

./skinr.module, line 268

Code

function skinr_form_validate(&$form, &$form_state) {
  $form_id = $form_state['values']['form_id'];
  $skinr_data = skinr_fetch_data();
  foreach ($skinr_data 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['advanced']['_additional'])) {
          $form_settings = array_merge(_skinr_fetch_data_defaults('form'), $settings['form'][$form_id]);

          // Validate additional classes field.
          if (preg_match('/[^a-zA-Z0-9\\-\\_\\s]/', $theme['advanced']['_additional'])) {
            form_set_error('skinr_settings][' . $module . '_group][' . $theme_name . '][advanced][_additional', t('Additional classes for Skinr may only contain alphanumeric characters, spaces, - and _.'));
          }

          // Keep looping, there might be other modules that implement the same form_id.
        }
      }
    }
  }
}