cfform

Builds a form with CFML custom control tags; these provide
more functionality than standard HTML form input elements.

  <cfform>

 cfform();

Attribute Reference

name string

In HTML format, if you omit this attribute and specify
an id attribute, ColdFusion does not include a name
attribute in the HTML sent to the browser; this
behavior lets you use the cfform tag to create
XHTML-compliant forms. If you omit the name
attribute and the id attribute, ColdFusion generates
a name of the form CFForm_n where n is a number
that assigned serially to the forms on a page.

action string

Name of CFML page to execute when the form is
submitted for processing.

method string
Default: post

The method the browser uses to send the form data
to the server:
- post: Send the data using the HTTP post method,
This method sends the data in a separate message
to the server.
- get: Send the data using the HTTP get method,
which puts the form field contents in the URL
query string.
Values:
  • post
  • get

format string
Default: html

- HTML: Generate an HTML form and send it to the client.
- Flash: DEPRECATED in CF 11+ Generate a Flash form and send it to the client. All controls are in Flash format.
- XML: DEPRECATED in CF 11+ Generate XForms-compliant XML and save
the results in a variable specified by the name
attribute. By default, ColdFusion also applies an XSL skin and displays the result.
Values:
  • html
  • flash
  • xml

skin string

DEPRECATED in CF 11+
Flash: Use a Macromedia halo color to stylize the output.
XML: Specifies whether to apply an XSL skin and
display the resulting HTML to the client. Can be any
of the following:
- ColdFusion MX skin name: Apply the specified skin.
- XSL file name: Apply the skin located in the specified path.
- "none": Do not apply an XSL skin. You must use XForms XML then.
- (omitted) or "default": Use the ColdFusion MX default skin.
Values:
  • haloSilver
  • haloBlue
  • haloGreen
  • haloOrange
  • beige
  • blue
  • bluegray
  • lightgray
  • red
  • silver
  • none
  • default
  • basic
  • basiccss

preservedata boolean
Default: false

When the cfform action attribute posts back to the same
page as the form, this determines whether to override the
control values with the submitted values.
- false: values specified in the control tag attributes are used
- true: corresponding submitted values are used
Values:
  • true
  • false

onload string

JavaScript to execute when the form loads.

onsubmit string

JavaScript or Actionscript function to execute to
preprocess data before form is submitted. If any
child tags specify onSubmit field validation, ColdFusion
does the validation before executing this JavaScript.

codebase string
Default: /CFIDE/classes/cf-j2re-win.cab

URL of downloadable JRE plug-in (for Internet Explorer only).
Default: /CFIDE/classes/cf-j2re-win.cab

archive string
Default: /CFIDE/classes/cfapplets.jar

URL of downloadable Java classes for CFML controls.
Default: /CFIDE/classes/cfapplets.jar

height string
Default: 100%

The height of the form. Use a number to specify
pixels, In Flash, you can use a percentage value to
specify a percentage of the available width. The
displayed height might be less than the specified size.

width string
Default: 100%

The width of the form. Use a number to specify
pixels, In Flash, you can use a percentage value to
specify a percentage of the available width.

onerror string

Applies only for onSubmit or onBlur validation; has
no effect for onServer validation. An ActionScript
expression or expressions to execute if the user
submits a form with one or more validation errors.

wmode string
Default: window

Specifies how the Flash form appears relative to
other displayable content that occupies the same
space on an HTML page.
- window: The Flash form is the topmost layer on the
page and obscures anything that would share the
space, such as drop-down dynamic HTML lists.
- transparent: The Flash form honors the z-index of
DHTML so you can float items above it. If the Flash
form is above any item, transparent regions in the
form show the content that is below it.
- opaque: The Flash form honors the z-index of
DHTML so you can float items above it. If the Flash
form is above any item, it blocks any content that is
below it.
Default is: window.
Values:
  • window
  • transparent
  • opaque

accessible boolean
Default: false

Specifies whether to include support screen readers
in the Flash form. Screen reader support adds
approximately 80KB to the SWF file sent to the
client. Default is: false.
Values:
  • true
  • false

preloader boolean
Default: true

Specifies whether to display a progress bar when
loading the Flash form. Default is: true.
Values:
  • true
  • false

timeout numeric

Integer number of seconds for which to keep the
form data in the Flash cache on the server. A value of
0 prevents the data from being cached.

scriptsrc string

Specifies the URL, relative to the web root, of the
directory that contains the cfform.js file with the
client-side JavaScript used by this tag and its child
tags. For XML format forms, this directory is also the
default directory for XSLT skins.

style string

Styles to apply to the form. In HTML or XML format,
ColdFusion passes the style attribute to the browser
or XML. In Flash format, must be a style specification
in CSS format.

onreset string

JavaScript to execute when the user clicks a reset button.

id string

HTML id passed through to
.

target string

Target window or frame passed through to .

passthrough string

DEPRECATED in CF 7+ REMOVED in CF 11+ Passes arbitrary attribute-value pairs to the HTML code
that is generated for the tag. You can use either of the
following formats:

passthrough="title=""myTitle"""
passthrough='title="mytitle"'

onsuccess string

Applies only to forms inside cfdiv, cflayout, cfpod, or cfwindow controls. The name of a JavaScript function that will run when an asynchronous form submission succeeds.

Compatibility

ColdFusion:

Version 3+ ColdFusion 11 DEPRECATED format=flash, format=xml and format=applet

Examples
Sample code using the cfform tag

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub