Creating fieldsets outside forms with minimal code

Every now and again there comes a time when you want to use form groups (HTML fieldset elements) without having a real form, simply because they make good containers for content.

With the old form code, we could happily write something like the following:

<?php
$output
.= form_group(t('My Fieldset'), $group);
?>

I dreaded the thought of creating a new $form, and all kinds of form API code just to create a fieldset, but luckily we can accomplish the same effect with only a minimal amount of fuss:

<?php
$output
.= theme('fieldset', array('#title' => t('My Fieldset'), '#children' => $group));
?>

 
 

Drupal is a registered trademark of Dries Buytaert.