ColdFusion Custom Tags for use with Uni-Form XHTML Forms
Posted on December 16, 2007 at 5:37 AM in ColdFusion, Uni-Form Tag Library
A few weeks ago I wrote about my joyous discovery of the Uni-Form markup, an XHTML Strict 1.0 valid markup for forms. At the time I had the thought of wrapping it up into a ColdFusion custom tag, but was way too busy with other items to even really look at it. Well, it just so happens that I've just gotten to the "time to write a bunch of forms for the admin interface" on a new project I'm working on, so off to write that tag I went.
(LOL @ "a tag" or "that tag". All told, it's ten (10) tags, although four of them could be eliminated if one really wanted to do so. But I use them over and over and over, and since that's the point of custom tags, I'm including them.)
We all know what a royal PITA it is to write a bunch of forms. All of that markup, over and over. Well, not anymore. Here's a brief example of what these tags do.
First, calling the tags...
- <cfimport taglib="/cfMgmt/tags/forms/UniForm" prefix="uform" />
- <uform:form action="myAction.cfm" method="post" id="myForm">
- <uform:fieldset legend="Required Fields" class="inlineLabels">
- <uform:field label="Email Address" name="emailAddress" isRequired="true" type="text" hint="Must be a valid email address." />
- <uform:field label="Choose Password" name="password" isRequired="true" type="password" />
- <uform:field label="Re-enter Password" name="password2" isRequired="true" type="password" />
- </uform:fieldset>
- </uform:form>
And here's the rendered markup...
- <form action="myAction.cfm" method="post" enctype="multipart/form-data" id="myForm" class="uniForm">
- <fieldset class="inlineLabels">
- <legend>Required Fields</legend>
- <div class="ctrlHolder">
- <label for="emailAddress"><em>*</em> Email Address</label>
- <input name="emailAddress" id="emailAddress" value="" size="35" maxlength="50" type="text" class="textInput" />
- <p class="formHint">Must be a valid email address.</p>
- </div>
- <div class="ctrlHolder">
- <label for="password"><em>*</em> Choose Password</label>
- <input name="password" id="password" value="" size="35" maxlength="50" type="password" class="textInput" />
- </div>
- <div class="ctrlHolder">
- <label for="password2"><em>*</em> Re-enter Password</label>
- <input name="password2" id="password2" value="" size="35" maxlength="50" type="password" class="textInput" />
- </div>
- </fieldset>
- <div class="buttonHolder">
- <button type="submit" class="submitButton"> Submit </button>
- <button type="submit" class="submitButton" name="cancel"> Cancel </button>
- </div>
- </form>
It's really difficult to make that look good in a blog post, but hopefully you can at least get a glimpse of how simple it is to use, and more importantly how many keystrokes you can save yourself. As I get the time, I'll try and post some more examples of how to use the tags.
The zip (download) contains all of the tags, which are heavily commented on their usage. The index.cfm file is the demo form that is used on the Uni-Form demo site, built with the help of the tags.
The tags are being released under the Apache License, Version 2. Please put them to good use. :)
Latest Articles
- No recent entries.
Categories
- ColdBox (21) [RSS]
- ColdFusion (92) [RSS]
- Fusebox (3) [RSS]
- General (22) [RSS]
- jQuery (15) [RSS]
- Kalendar (1) [RSS]
- Linux (1) [RSS]
- Mura CMS (1) [RSS]
- Railo (1) [RSS]
- Rants (5) [RSS]
- Transfer (8) [RSS]
- Uni-Form Tag Library (36) [RSS]
Quick Links
Blogs I Read
Calendar
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
« Feb | ||||||
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Subscribe
Enter a valid email address.
On 12/17/07 at 6:15 AM, Ben Nadel said:
On 12/17/07 at 8:42 AM, Tony Petruzzi said:
Even with the way I describe, it isn't perfect. I would to see HTML5 have a require attribute for form fields. That would make it fool proof for screen readers.
On 12/18/07 at 12:15 PM, Sean Corfield said:
On 4/8/08 at 12:54 PM, Dan Wilson said:
DW
On 4/23/08 at 8:09 AM, Dan O'Keefe said:
Thanks
On 4/23/08 at 12:44 PM, Matt Quackenbush said: