You are here

function themekey_rule_chain_form_set_error in ThemeKey 6.4

Same name and namespace in other branches
  1. 6.2 themekey_admin.inc \themekey_rule_chain_form_set_error()
  2. 6.3 themekey_admin.inc \themekey_rule_chain_form_set_error()

Implements an error stack for hemekey_rule_chain_form()

Parameters

$form: drupal form as reference

$rule_id: the id of a ThemeKey rule

$element: the id of an errounous form element as string

$msg: error message as string

See also

hemekey_rule_chain_form()

themekey_form_alter()

1 call to themekey_rule_chain_form_set_error()
themekey_form_alter in ./themekey_admin.inc
Implements hook_form_alter().

File

./themekey_admin.inc, line 365

Code

function themekey_rule_chain_form_set_error(&$form, $rule_id = 0, $element = '', $msg = '') {
  static $error_stack = array();
  if (!empty($rule_id)) {
    $error_stack[$rule_id][] = array(
      'old_items][' . $rule_id . '][' . $element,
      $msg,
    );
  }
  else {
    $error_counter = 0;
    foreach ($error_stack as $rule_id => $errors) {
      $error_counter++;
      $form['old_items'][$rule_id]['id']['#prefix'] = '<span class="error">' . $error_counter . '</span>';
      foreach ($errors as $error) {
        form_set_error($error[0], $error_counter . ') ' . $error[1]);
      }
    }
    if (0 < $error_counter) {
      drupal_set_message(t("Your current configuration of Theme Switching Rules contains at least one logical error. Nevertheless this configuration is stored and active."), 'warning');
    }
  }
}