You are here

function variable_realm_union_variable_settings_form_alter in Variable 7

Implements hook_variable_settings_form_alter().

Make sure realm switchers are added for all realms in the union.

File

variable_realm_union/variable_realm_union.variable.inc, line 67
Variable hooks for variable_realm_union.

Code

function variable_realm_union_variable_settings_form_alter(&$form, &$form_state, $form_id) {
  foreach (variable_realm_union() as $realm_name => $union_realms) {
    if (!empty($form['#realm_variables'][$realm_name]) && empty($form[VARIABLE_REALM_FORM_SWITCHER . $realm_name])) {

      // Check we have selectors for the other realms.
      foreach ($union_realms as $realm) {
        $info = variable_realm_info($realm);
        if (!empty($info['form switcher']) && empty($form[VARIABLE_REALM_FORM_SWITCHER . $realm])) {
          $current_key = variable_realm_form_key_current($realm);
          $form += variable_realm_form_key_selector($realm, $current_key);
        }
      }
    }
  }
}