Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
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 <em>yourthemename</em>.
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);
}
Comments
Register function before editing
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:
source: http://www.lullabot.com/articles/modifying-forms-drupal-5-and-6
Single use.
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.