Skip to main content
deleted 10 characters in body
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

The theme-settings.php is included from system_theme_settings(), which executes the following code.

// Call engine-specific settings.
$function = $themes[$key]->prefix . '_engine_settings';
if (function_exists($function)) {
  $form['engine_specific'] = array(
    '#type' => 'fieldset', 
    '#title' => t('Theme-engine-specific settings'), 
    '#description' => t('These settings only exist for the themes based on the %engine theme engine.', array('%engine' => $themes[$key]->prefix)),
  );
  $function($form, $form_state);
}
foreach ($theme_keys as $theme) {
  // Include the theme-settings.php file.
  $filename = DRUPAL_ROOT . '/' . str_replace("/$theme.info", '', $themes[$theme]->filename) . '/theme-settings.php';
  if (file_exists($filename)) {
    require_once $filename;
  }

  // Call theme-specific settings.
  $function = $theme . '_form_system_theme_settings_alter';
  if (function_exists($function)) {
    $function($form, $form_state);
  }
}

Unfortunately, the file is not loaded from Drupal before any validation/submission handlers for that form are invoked.

When form_cache_get() is called, the following code is executed.

    foreach ($form_state['build_info']['files'] as $file) {
      if (is_array($file)) {
        $file += array('type' => 'inc', 'name' => $file['module']);
        module_load_include($file['type'], $file['module'], $file['name']);
      }
      elseif (file_exists($file)) {
        require_once DRUPAL_ROOT . '/' . $file;
      }
    }

As form_get_cache() seems called before a form is validated/submitted, you could use the following code. (Replace mytheme with the short name of your theme.)

function mytheme_form_system_theme_settings_alter(&$form, &$form_state) {
  $theme = $GLOBALS['theme_key'];
  $themes = $themes = list_themes();

  $form_state['build_info']['files'][] = str_replace("/$theme.info", '', $themes[$theme]->filename) . '/theme-settings.php';
}

The theme-settings.php is included from system_theme_settings(), which executes the following code.

// Call engine-specific settings.
$function = $themes[$key]->prefix . '_engine_settings';
if (function_exists($function)) {
  $form['engine_specific'] = array(
    '#type' => 'fieldset', 
    '#title' => t('Theme-engine-specific settings'), 
    '#description' => t('These settings only exist for the themes based on the %engine theme engine.', array('%engine' => $themes[$key]->prefix)),
  );
  $function($form, $form_state);
}
foreach ($theme_keys as $theme) {
  // Include the theme-settings.php file.
  $filename = DRUPAL_ROOT . '/' . str_replace("/$theme.info", '', $themes[$theme]->filename) . '/theme-settings.php';
  if (file_exists($filename)) {
    require_once $filename;
  }

  // Call theme-specific settings.
  $function = $theme . '_form_system_theme_settings_alter';
  if (function_exists($function)) {
    $function($form, $form_state);
  }
}

Unfortunately, the file is not loaded from Drupal before any validation/submission handlers for that form are invoked.

When form_cache_get() is called, the following code is executed.

    foreach ($form_state['build_info']['files'] as $file) {
      if (is_array($file)) {
        $file += array('type' => 'inc', 'name' => $file['module']);
        module_load_include($file['type'], $file['module'], $file['name']);
      }
      elseif (file_exists($file)) {
        require_once DRUPAL_ROOT . '/' . $file;
      }
    }

As form_get_cache() seems called before a form is validated/submitted, you could use the following code. (Replace mytheme with the short name of your theme.)

function mytheme_form_system_theme_settings_alter(&$form, &$form_state) {
  $theme = $GLOBALS['theme_key'];
  $themes = $themes = list_themes();

  $form_state['build_info']['files'][] = str_replace("/$theme.info", '', $themes[$theme]->filename) . '/theme-settings.php';
}

The theme-settings.php is included from system_theme_settings(), which executes the following code.

// Call engine-specific settings.
$function = $themes[$key]->prefix . '_engine_settings';
if (function_exists($function)) {
  $form['engine_specific'] = array(
    '#type' => 'fieldset', 
    '#title' => t('Theme-engine-specific settings'), 
    '#description' => t('These settings only exist for the themes based on the %engine theme engine.', array('%engine' => $themes[$key]->prefix)),
  );
  $function($form, $form_state);
}
foreach ($theme_keys as $theme) {
  // Include the theme-settings.php file.
  $filename = DRUPAL_ROOT . '/' . str_replace("/$theme.info", '', $themes[$theme]->filename) . '/theme-settings.php';
  if (file_exists($filename)) {
    require_once $filename;
  }

  // Call theme-specific settings.
  $function = $theme . '_form_system_theme_settings_alter';
  if (function_exists($function)) {
    $function($form, $form_state);
  }
}

Unfortunately, the file is not loaded from Drupal before any validation/submission handlers for that form are invoked.

When form_cache_get() is called, the following code is executed.

    foreach ($form_state['build_info']['files'] as $file) {
      if (is_array($file)) {
        $file += array('type' => 'inc', 'name' => $file['module']);
        module_load_include($file['type'], $file['module'], $file['name']);
      }
      elseif (file_exists($file)) {
        require_once DRUPAL_ROOT . '/' . $file;
      }
    }

As form_get_cache() seems called before a form is validated/submitted, you could use the following code. (Replace mytheme with the short name of your theme.)

function mytheme_form_system_theme_settings_alter(&$form, &$form_state) {
  $theme = $GLOBALS['theme_key'];
  $themes = list_themes();

  $form_state['build_info']['files'][] = str_replace("/$theme.info", '', $themes[$theme]->filename) . '/theme-settings.php';
}
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

The theme-settings.php is included from system_theme_settings(), which executes the following code.

// Call engine-specific settings.
$function = $themes[$key]->prefix . '_engine_settings';
if (function_exists($function)) {
  $form['engine_specific'] = array(
    '#type' => 'fieldset', 
    '#title' => t('Theme-engine-specific settings'), 
    '#description' => t('These settings only exist for the themes based on the %engine theme engine.', array('%engine' => $themes[$key]->prefix)),
  );
  $function($form, $form_state);
}
foreach ($theme_keys as $theme) {
  // Include the theme-settings.php file.
  $filename = DRUPAL_ROOT . '/' . str_replace("/$theme.info", '', $themes[$theme]->filename) . '/theme-settings.php';
  if (file_exists($filename)) {
    require_once $filename;
  }

  // Call theme-specific settings.
  $function = $theme . '_form_system_theme_settings_alter';
  if (function_exists($function)) {
    $function($form, $form_state);
  }
}

Unfortunately, the file is not loaded from Drupal before any validation/submission handlers for that form are invoked.

When form_cache_get() is called, the following code is executed.

    foreach ($form_state['build_info']['files'] as $file) {
      if (is_array($file)) {
        $file += array('type' => 'inc', 'name' => $file['module']);
        module_load_include($file['type'], $file['module'], $file['name']);
      }
      elseif (file_exists($file)) {
        require_once DRUPAL_ROOT . '/' . $file;
      }
    }

As form_get_cache() seems called before a form is validated/submitted, you could use the following code. (Replace mytheme with the short name of your theme.)

function mytheme_form_system_theme_settings_alter(&$form, &$form_state) {
  $theme = $GLOBALS['theme_key'];
  $themes = $themes = list_themes();

  $form_state['build_info']['files'][] = str_replace("/$theme.info", '', $themes[$theme]->filename) . '/theme-settings.php';
}