Creating Forms with the CFFORM Tag

You've already learned how to use HTML forms to gather user input. (See "Using Forms to Specify the Data to Retrieve".) 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:

With CFFORM, you gain the advantage of access to these Java applet-based controls without having to know the Java language, and, you don't 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 don't have to write separate CFML code specifically for input validation as you do in HTML forms.

Using HTML in a CFFORM

You can use the HTML FORM tag in combination with the CFFORM tag. ColdFusion generates HTML forms dynamically from CFFORM tags and passes through to the browser any HTML code it finds in the form. 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 will be passed through to the HTML generated by these form tags. You can also replace your existing HTML FORM tags with CFFORM and your forms will work fine.

CFFORM controls

Forms created using CFFORM use one or more of the following controls:

CFFORM Controls 
Control Description
CFGRID
A Java applet-based control used to create a data grid you can populate from a query or by defining the contents of individual cells. Grids can also be used to insert, update, and delete records from a data source.
CFSLIDER
A Java applet-based control used to define a slider.
CFINPUT
Used to place radio buttons, check boxes, text input boxes, and password entry boxes.
CFTREE and 
CFTREEITEM
Java applet-based controls used to define a tree control and individual tree control items.
CFTEXTINPUT
A Java applet-based control used to define a text input box.
CFSELECT
Used to define a drop-down list box.
CFAPPLET
Used to embed your own Java applets.

Improving performance with ENABLECAB

The CFFORM ENABLECAB attribute allows you to improve the performance of Java-applet based CFFORM controls. When you use ENABLECAB, ColdFusion prompts the end user to accept a download of the Java classes needed for the CFFORM controls that use them. CAB files are digitally signed using VeriSign digital IDs to ensure file security.

Note The ENABLECAB attribute is supported only for MS Internet Explorer clients that have Authenticode 2.0 installed. Authenticode 2.0 can be downloaded from http://www.microsoft.com/Windows/ie/security/ authent2.asp.

Browsers that disable Java

Since each of the Java applet-based controls, CFGRID, CFSLIDER, CFTEXTINPUT, and CFTREE require a Java applet to run, browsers that do not support Java or that have disabled Java execution will not execute the forms that contain these controls. Using the NOTSUPPORTED attribute, ColdFusion allows you to present an error message rather than the blank applet space that appears in the browser. This attribute is available in each of the Java applet-based controls as well as the CFAPPLET tag. You use NOTSUPPORTED to specify the message you want to appear, formatted as HTML, when an application page is loaded by a browser that does not support Java.