This page displays the "Global Config" demo form. You can create a GlobalConfig struct in CFML, or if you are utilizing a DI framework such as ColdSpring, you can create your config inside of it. (See the code page for an example.)

You can use keys matching any valid attribute on the form tag. Then simply provide your config struct to the form via the attributeCollection, as shown below.

<uform:form attributeCollection="#cfUniFormConfig#">

By utilizing the attributeCollection, we can take advantage of ColdFusion's handling of attributeCollection keys vs. explicitly declared keys. What do I mean by that? Well, if you have a key in the struct that is passed via attributeCollection but also explicitly provide that same key, ColdFusion will automatically use the value provided by the explicit key instead. This allows us to provide a global config, and yet still override it at the form level!

We demonstrate this in the form on this page by explicitly providing the 'dateSetup' key, even though it exists in the attributeCollection. Note that the cfUniFormConfig struct's dateSetup sets the yearRange to year(now()) [2010] through year(now()+2) [2012].

cfUniFormConfig.dateSetup['yearRange'] = "'#year(now())#:#year(dateAdd('yyyy', 1, now()))#'";

However, since we've explicitly provided a range of 2000-2005 via the 'dateSetup' key...

<uform:form attributeCollection="#cfUniFormConfig#" dateSetup="{yearRange:'2000:2005'}">

...ColdFusion gives precedence to the explicit declaration, and the form contains the latter setup. Thank you, CF!!

A few important notes:

View the code used to generate the form.


Task Details

Enter a name to remember your task by (e.g. Pick up laundry)

Enter a detailed description of the task (e.g. directions to the cleaners).