cfUniForm New Release - v2.1
Posted on July 19, 2008 at 4:39 PM in ColdFusion, Uni-Form Tag Library
The latest release of cfUniForm includes a couple of new features, along with a minor bug fix.
New Features: type="custom"
It always seems that no matter how hard you try to include every possible scenario in your tag library, there's always a new implementation need that pops up that hadn't previously been thought of. For those situations, you can now use type="custom" to do whatever you need to do.
- <uform:field type="custom">
- <p>
- I exist in the middle of this form just
- for the sake of being annoying.
- </p>
- <hr />
- <p>
- Actually, not really. I am here just
- to prove a point. With type="custom"
- the developer can do whatever he or she
- wants to do with their forms.
- </p>
- <p>
- Like maybe placing a "Check Availabilty"
- button on a new user registration form
- that sends an Ajax request to the server
- to see if the desired User Name is available.
- </p>
- <button>Check Availability</button>
- </uform:field>
One word of caution with type="custom". For those of you who actually care about whether or not your markup is valid, be careful about what you place in a custom field, as the library will not do a validation check for you.
New Features: errorMessagePlacement
There is a brand new (optional) argument on the base form tag (<uform:form>) called 'errorMessagePlacement'. This argument does exactly what the name implies, and accepts the following values: top, inline, both, none.
- top - display the errors only at the top of the form (above the fields)
- inline - display the errors only inline (with the offending field)
- both - display both at the top and inline (this is the default)
- none - no error message display
For what it's worth, I really don't know why you'd want to use 'none', since you can achieve the same result by simply not passing an error struct to the tag. However, I included the option nonetheless. Maybe there's a specific use case out there where it might come in handy.
Minor Bug Fix
In previous versions, type="checkbox" did not support the 'isChecked' attribute. This has been fixed in the 2.1 release.
Demo and Download
You can see a quick demo here, or you can download the zip here.
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 |
---|---|---|---|---|---|---|
« Mar | ||||||
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 |
Subscribe
Enter a valid email address.
On 8/2/08 at 12:46 PM, Josen Ruiseco said:
Thanks to you for all your hard work bringing the power and simplicity of uniforms to to ColdFusion.
Have you configured the twoSelectsRelated custom tag to work with your code?
Josen
On 8/2/08 at 4:14 PM, Matt Quackenbush said:
You're welcome. :-) I have not done anything with the twoSelectsRelated tag, but it should be possible to use it in conjunction with the new type="custom" feature, since it will allow you to do anything inside of it.
HTH
On 8/13/08 at 2:08 AM, Matt MacDougall said:
I just noticed on the demo that the DOB field shows the calendar with the first year as 98 and the last as several years in the future. I think an attribute for the date type to set the year range would be helpful.
This tag has become an integral part of my workflow. Thanks for the work!
-Matt
On 8/13/08 at 2:56 AM, Matt Quackenbush said:
Glad you find the tags useful!
The datepicker is very customizable, and therefore has a lot of options that can be set. IMO, it would be a treacherous path to go down if there were attributes for all of the options for all of the plugins. If you need to make changes to the defaults, I would suggest either adding a script block (after your form) to set the defaults, or just load the datepicker on your own and set the defaults when you load it.
Here's an example of changing the date range:
<script type="text/javascript">
$(document).ready(function() {
$.datepicker.setDefaults({yearRange: "2001:2004"});
});
</script>
There are quite a number of things you can change. Take a look at the docs (http://docs.jquery.com/UI/Datepicker) for all of the specifics.
On 8/13/08 at 4:04 PM, Matt MacDougall said:
Using a bit of JS to change this is a not a big deal. I'll either go that route or make a patch for this to be able to set a -years or +years from today for the range in the past or future years. It is something I think we as users should be doing everytime we use this field for data collection. So maybe it's one of those attributes that should be included in the base ...
On 8/14/08 at 2:15 PM, John said:
errorMessage attribute for a field doesn't seems to work.
Can you confirm this or do you have or a snippet of code ?
Thanks
John.
On 8/14/08 at 2:45 PM, Matt Quackenbush said:
Thanks for the kind words. :-)
The errorMessage attribute... When I first read your comment, I had to think really hard about that, because I had forgotten that it even existed. When I added the errors struct attribute, my intention was for the individual errorMessage attribute to go away. The behavior that you're seeing is the result of that, I just (obviously) never removed that attribute from the tag.
Essentially, the idea is that after you do server-side validation, you'll pass a struct into the errors attribute on the form, which will contain all of your error messages for each field. So, for instance, let's say you have a form field named 'userName', and the field fails validation. Here's an example of how you might handle passing error messages for that field:
<cfscript>
errors = structNew();
errors.userName = "User Name contains invalid characters.";
</cfscript>
When the form is generated, it will search for a key in the errors struct whose name matches the name of the field being built. If one is found, then it is added into the source code. By handling it this way, I feel that it provides a better separation of logic and HTML, as well as gives you more control to build all of your error messages in a single place, such as your controller or a validation object.
Does that make sense?
Now then, for client-side validation error messages, I personally typically just use the default error messages that are built into the jQuery validation plugin. On the occasion that I need to do any "serious" client-side validation routines, I typically don't have the tags load the validation plugin, and then I write my own script for that particular form. You can find more info about the plugin by checking out the docs (http://docs.jquery.com/Plugins/Validation).
Hope that helps.