When changing variables in the admin settings page, clicking submit does not update timer.js with the new "just changed" settings.
only when clicking submit again the file timer.js is updated with the right values.

The reason for that is the call for _build_js_cache from countdowntimer_admin_settings_validate function.
In this stage of validation, the variables are not yet stored in the database and when calling
variable_get in _build_js_cache() => _get_javascript()
you get the old values and not the "just changed" values.

my suggestion for fix is:

1) in function countdowntimer_admin_settings() add submit handler to be called after system_settings_form_submit
2) move the call to _build_js_cache() to a new submit handler called after system_setting_form_submit

function countdowntimer_admin_settings() {
  ...
  $form = system_settings_form($form);
  $form['#submit'][] = 'countdowntimer_admin_settings_submit';  // add submit handler

  return $form;
}

function countdowntimer_admin_settings_validate($form, &$form_state) {
  ...
  // build timer.js file with new settings.
  '**REMOVE THIS LINE**' ==>  _build_js_cache();
}

// Submit handler
function countdowntimer_admin_settings_submit($form, &$form_state) {
  ...
  // build timer.js file with new settings.
  _build_js_cache();
}

Comments

jvandervort’s picture

Status: Needs review » Fixed

Patch looks good, tested successfully, committed.

Status: Fixed » Closed (fixed)

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