Community Documentation

Creating fieldsets outside forms with minimal code

Last updated November 12, 2005. Created by Thox on November 12, 2005.
Edited by Dublin Drupaller. Log in to edit this page.

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));
?>

Archive

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.