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:
* Format a group of form items.
* @param $element
* An associative array containing the properties of the element.