Using a fieldset to group fields
The FIELDSET
element is used to group related fields together and can be seen extensively in Drupal forms. While we saw how to inject markup in the previous recipe to group fields from a styling point of view, in this recipe we will be looking at grouping related fields of the contact form using two separate fieldsets.
Getting ready
We will be using the mysite module created earlier in this book to hold our customizations. As we are altering the contact form, it is assumed that the contact module is enabled and configured with at least a couple of contact categories via its management page at admin/build/contact
(Home | Administer | Site building | Contact form). Enabling the module automatically makes a menu item available which can also be enabled from the menu management page at admin/build/menu
(Home | Administer | Site building | Menus).
The form is accessible via the URL contact
and should look something like the following screenshot:
How to do it...
Navigate...