the way i do it is:
a) <cfparam> each and every form var used on the page:
if it's an
'insert/add' page - cfparam then to default values you need;
on an
'update/edit' page cfparam them to values returned by the
query taht
pulls the data to be edited from the db. it get a little bit
trickier
with radio buttons/checkboxes/file uploads, but nothing too
tricky.
b) each form field on the page has a value set to same name
#form.formfield#, i.e. <input type='text' name='fname'
value='#form.fname#'> - since i cfparam all of them, these
FORM scope
vars are available to me even without submitting the form.
c) validate some form data on the client side using custom js
and/or
cform's required attribute validation
d) validate all form data for value required and data format
on the
server using cfif/cfelse and/or cfswitch/cfcase logic as
necessary. i
usually set an err var (i.e. <cfset err = 0>) and
errmsg var (i.e.
<cfset errmsg = "">) BEFORE the validation code block,
then if a form
field does not validate i cfset err = 1 and errmsg = errmsg
& "some text
about this error;<br />". then my db inserts/updates
are inside a cfif
block which checks that err = 0.
e) in my from i have another cfif block that checks for err
gt 0 and if
so cfoutputs #errmsg#. since all form fields have value set
to their
value as described in b) above, all data posted by user is
preserved in
the form. with file upload fields i usually do file upload
only if
server-side form data validation succeeds; a user has to
re-select a
file if form does not validate which is not too much of an
inconvenience, especially if you remind the user in your
error message
to re-select the file...
now, the above is not a perfect solution, and in other cases
may be an
overkill. this is just something i do. i could have forgotten
to mention
something since it is pretty late here and i am rather tired.
if i do
remember it tomorrow i will post more...
hth
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/