Fieldsets

Adding IDs to all Fieldsets

A themer on a project I was recently working on needed a lot of CSS IDs added to fieldsets throughout the site.

Fortunately, there's a theme_fieldset() function in includes/forms.inc

I was able to copy that function into the phptemplate.php file, obviously change theme_ to phptempalte_ in the function name, and then add logic that adds an ID based on the fieldset name if an id does not already exist.

Here's the code:

  1. /**
  2.  * Format a group of form items.
  3.  *
  4.  * @param $element
  5.  * An associative array containing the properties of the element.