Last updated 5 October 2010. Created on 4 March 2010.
Edited by siliconmeadow, droofan. Log in to edit this page.

By default the theme settings form has all core fieldsets expanded, even though they do not contain required fields. Especially when you are expanding the theme settings with your own form elements, the expanded core fieldsets create a disorganized view.

The solution is a theme override to be placed in your template.php file (see Overriding themable output for a general overview of overrides and where to place this code):

// Override theme settings form to collapse logo image fieldset and shortcut icon fieldset. You should put the name of your theme where it says yourthemename.
function yourthemename_system_settings_form($form) {
  // Collapse fieldsets
  $form_elements = element_children($form);
  foreach ($form_elements as $element) {
    if ($form[$element]['#type'] == 'fieldset') { //Identify fieldsets and collapse them
      $form[$element]['#collapsible'] = TRUE;
      $form[$element]['#collapsed']   = TRUE;
    }
  }
  return drupal_render($form);
}

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

Wemagine’s picture

Thanks, I was looking for this! Just be sure to register the function before placing this in your template.php. I didn't know about this step and it took me quite a while to figure it out.

You can register the function like this:

/**
* Implementation of hook_theme.
*
* Register custom theme functions.
*/
function themename_theme() {
  return array(
    // The form ID.
    'system_settings_form' => array(
      // Forms always take the form argument.
      'arguments' => array('form' => NULL),
    ),
  );
}

source: http://www.lullabot.com/articles/modifying-forms-drupal-5-and-6

lahoosascoots’s picture

If you don't have theme access or want to pick and choose which fieldsets to collapse you can change Fieldgroup setting to 'collapsed' in the configuration for each fieldset to be collapsed. You can find this in the "Manage Fields" section of your content type.