It seems that the realm switcher does not work anymore on variable edit pages, e.g. admin/config/system/variable/group/site_information.

Saving still seems to work, but the values being displayed are not loaded accorded to the selected realm...

Comments

bforchhammer’s picture

Status: Active » Needs review
StatusFileSize
new717 bytes

The problem was that realms were not be switched if the fourth path element was "variable"; I'm not sure why that's there...

Jose, is it acceptable to just remove that part of the if condition?

jose reyero’s picture

Status: Needs review » Needs work

The idea is that forms in 'variable module' pages should handle the realms themselves (before building the forms) so we shouldn't be using 'hacks' like switching the global variables for that.

jose reyero’s picture

As a first step, merged variable_realm_admin module into variable_admin so the module is full aware of realms and we can skip realm hooks stepping into 'regular' variable_admin forms.

jose reyero’s picture

Status: Needs work » Fixed

Finally, added some realm parameters for all these admin pages.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

stborchert’s picture

Status: Closed (fixed) » Active
StatusFileSize
new1.08 KB

Sorry to re-open but I think I stumbled upon the same problem using version 2.1 of Variable (and latest Commerce Email). Maybe its an issue of Commerce Email but changing a line in variable.module fixed this for me.

Commerce Email uses 'page arguments' => array('variable_group_form', 'commerce_email'), in hook_menu to "create" its settings page. I noticed that the realm switcher is not displayed on this form (admin/commerce/config/email) because the function variable_form_alter() does call the implementations of hook_variable_settings_form_alter() only for forms having "system_settings_form_submit" as submit callback.
variable_group_form() however is using "variable_settings_form_submit".

Changing variable_form_alter() to this helped (simply moved the foreach outside the if-clause):

<?php
function variable_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['#submit']) && is_array($form['#submit']) && in_array('system_settings_form_submit', $form['#submit'])) {
    // Replace submit callback and use our own function.
    $form['#submit'] = str_replace('system_settings_form_submit', 'variable_settings_form_submit', $form['#submit']);
  }
  foreach (module_implements('variable_settings_form_alter') as $module) {
    $function = $module . '_variable_settings_form_alter';
    $function($form, $form_state, $form_id);
  }
}
?>

(attached patch is based on version 7.x-2.1)

bforchhammer’s picture

Status: Active » Closed (fixed)

Your patch would cause variable to act on every drupal form; I don't think that's something we want to do...

Either way, this sounds like a different issue; can you open up a new one?

This is possibly also related to #1602098: Variable realm edit pages broken for multiple realms.