User Guide
136 Chapter 9 Building Dynamic Forms
Creating Forms with the cfform Tag
You already learned how to use HTML forms to gather user input (see “Using Forms
to Specify the Data to Retrieve” on page 40). This chapter shows you how to use the
cfform tag to create dynamic forms in CFML. In addition to HTML control types,
you can use
cfform to create forms that contain controls such as:
• Text boxes in which you can specify the appearance, such as fonts and colors
• Predefined ColdFusion Java applet based controls, including trees, sliders, and
grids
• Custom Java applets that act as form elements
With
cfform, you can access these Java applet-based controls without knowing the
Java language, and you do not have to juggle
cfoutput tags and HTML form tags to
reference ColdFusion variables in your forms.
In addition, most cfform controls offer input validation attributes you can use to
validate a user’s entry, selection, or interaction. This means you do not have to write
separate CFML code specifically for input validation, as you do in HTML forms.
Using HTML and cfform
ColdFusion generates HTML forms dynamically from cfform tags and passes
through to the browser any HTML code it finds in the form. As a result, you can also
do the following:
• You can use the HTML form tag and form control tags in combination with the
cfform tag.
• You can use the passthrough attribute of the cfform, cfinput, and cfselect tags
to enter any HTML attributes that are not explicitly allowed in these tags. The
attribute values are passed through to the HTML generated by these form tags.
• You can replace your existing HTML
form tags with cfform and your forms will
work fine.