User Guide

Table Of Contents
Creating custom forms with the cfform tag 633
Preserving input data with the preservedata attribute
The
cfform preservedata attribute tells ColdFusion to continue displaying the user data in a
form after the user submits the form. Data is preserved in the
cfinput, cfslider, cftextinput,
and
cftree controls and in cfselect controls populated by queries. If you specify a default value
for a control, and a user overrides that default in the form, the user input is preserved.
You can retain data on the form when the same page contains the form and the forms action
code; that is, the form submits to itself. You can also retain the data if the action page has a copy
of the form, and the control names are the same in the forms on both pages. (The action page
form does not need to be identical to the initial form. It can have more or fewer elements than the
initial page form; only the form elements with identical names on both pages keep their data.)
Note: The preservedata setting on the action page controls the preservation of the data.
For example, if you save this form as preserve.cfm, it continues to display any text that you enter
after you submit it, as follows:
<cfform action="preserve.cfm" preservedata="Yes">
<p>Please enter your name:
<cfinput type="Text" name="UserName" required="Yes"><p>
<input type="Submit" name=""> <input type="RESET">
</cfform>
Usage notes for the preservedata attribute
When you use the
preservedata attribute, follow these guidelines:
In the cftree tag, the preservedata attribute causes the tree to expand to the previously
selected element. For this to work correctly, you must also set the
completePath attribute to
True.
The preservedata attribute has no effect on a cfgrid tag. If you populate the control from a
query, you must update the data source with the new data (typically by using a
cfgridupdate
tag) before redisplaying the grid. The grid then displays the updated database information.
cfselect Displays a selection box. Equivalent to the
HTML
select tag, with the addition of input
validation.
“Building drop-down list boxes”
on page 642
cfslider Creates a Java applet-based control that lets
users enter data by moving a slider. Not
supported in Flash format forms.
“Building slider bar controls”
on page 643
cftextarea Displays a text input area. Equivalent to the
HTML
textarea tag, with the addition of input
validation.
The
cftextarea tag in CFML
Reference
cftree Creates a Java applet or Flash hierarchical tree-
format control that can include graphical images
for the different elements. Can also generate a
ColdFusion structure that represents the tree
data and attributes.
“Building tree controls with the
cftree tag” on page 634
Control Description For more information