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.
- Put this file in your cookbook directory: formextensions.phpΔ
- Add this line to your config.php:
- 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":) (:fieldsetend:) (: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 http://www.essentialclarity.com/Coaching/SignUp . (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.
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.
- FormsPlus - Form extensions adding new HTML5 input types
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.