Summary: adds fieldset, legend, and label tags to PmWiki forms
Version: 1.0
License: "no license: modify and distribute freely"
Status: in active use at,
Maintainer: Ben Stallings
Categories: Forms

Questions answered by this recipe

How can I use PmWiki to generate XHTML's <fieldset>, <legend>, and <label> tags in my forms?

How can I easily add a button to a page that causes all checkboxes on that page to toggle to the opposite state?


Enter your recipe's description here.

  1. Put this file in your cookbook directory: formextensions.phpΔ
  2. Add this line to your config.php: include_once "$FarmD/cookbook/formextensions.php";
  3. Use the markup as shown below.

Since a legend is only ever used in conjunction with a fieldset, it has been moved inside the fieldset tag, to eliminate the need for a separate (:legend:) tag. Similarly, the text of a label has been moved into the label tag to eliminate the need for a separate (:labelend:) tag. However, note that an input must have an id that matches the label.

(:input form:)
(:fieldset "What is your favorite primary color?":)
(:input radio color red id=red:) (:label red "Red like the sunset":)\\
(:input radio color green id=green:) (:label green "Green like the grass":)\\
(:input radio color blue id=blue:) (:label blue "Blue like the ocean":)
(:input submit:)
(:input end:)

The example code above will result in the three radio buttons being surrounded by a box with "What is your favorite primary color" at the top. The text beside each radio button will be clickable to activate the corresponding button. See a working example at . (Please don't submit the form unless you really want what it's offering.)


This recipe is called "Form Extensions" because I plan to add additional features soon. Here's my current wish list; feel free to add features you'd like to see.

  • Allow checking a box or radio button to change the style of the corresponding label, for example to bold. (requires JavaScript)
  • Allow resizable textareas like those in Drupal. (requires JavaScript)
  • Allow combo boxes like those in FreeBase, with contents generated by a pagelist. (requires JavaScript)
  • Allow calculated inputs, for example a field that shows the total of a number of other fields. (requires JavaScript)

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

  • 2007-03-26: Version 1.0
  • 2008-06-14: added (:toggleboxes:) markup to create a button that toggles all checkboxes on the page. This could be modified to only toggle boxes that match a pattern, but I haven't done that yet.

See Also

  • FormsPlus - Form extensions adding new HTML5 input types


Ben Stallings


See discussion at FormExtensions-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.