To generate XForms XML simple specify format="xml" in the <cfform> tag. Here is a simple example: <cfform format="xml" action="process.cfm"> <cfinput name="nameFirst" label="First Name:" type="text"> <cfinput name="nameLarst" label="Last Name:" type="text"> <cfinput name="btn" type="submit" value="Process"> </cfform> The above code contains no formatting, and yet if processed by ColdFusion would generate a form formatted and laid out in an HTML table. As no skin was specified, the default skin was used, and if you look at the generated source (do a View Source in the browser) you will see that an HTML table was generated automatically (by the XSL transformation). Applying XSL SkinsTo use one of the provided skins, the <cfform> can be modified so that it reads: <cfform format="xml" skin="silver" action="process.cfm"> This will generate a nicely formatted form using a silver theme. By simply specifying an alternate skin a different output could be generated. The following skins are included with ColdFusion:
The provided skins are intended to be examples and starting points for your own skins. And once written, your own skins can be used just as easily. Consider the following example: <cfform format="xml" skin="mySkin" action="process.cfm"> <cfformgroup type="myLayout"> <cfinput name="nameFirst" label="First Name:" type="text"> <cfinput name="nameLarst" label="Last Name:" type="text"> <cfinput name="btn" type="submit" value="Process"> </cfformgroup> </cfform> In this example a skin named mySkin is being used, and any and all formatting and presentation is included within that XSL file. A <cfformgroup> is used to group fields together, and ColdFusion allows any group type to be used because it actually does nothing with the specified type, other than simply include it in the generated XML (which is then translated by the XSL skin). The XSL file would have to know what to do with a type of myLayout and would render presentation accordingly. XSL Skin LocationsXSL skins can be shared system skins or application specific skins.
Usage NotesA few important notes pertaining to XForms and their use within ColdFusion:
NOTE If you are looking for additional examples of XSL skins and use, visit http://www.cfform.com/. |