One way that I have seen it/done it that I like pretty well is to avoid
cflocating by having an if statement in the cfcase:

- When a user submits a form (file called frm_formname), the action is
index.cfm?fa=save (or whatever)
- first file processed is err_formname.cfm, which does error checking, and
creates an error message variable
- next, back in the index..cfm, we check for the len of the error message
variable
    - if it is GT 0, we have an error, and we now include the frm_formname
file, which has an error display box at the top only when there is an error
mesage, so the user can edit the submission and fix it
    - if the error message var is len 0, everything went fine, so now we can
include the act_saveinfo.cfm file or qry_write to database.cfm file or
whatever.
- if there was a successful submission, then we can cflocate to a thank-you
page or confirmation page.  We cflocate so that if the user hits the back
button, they go back to the form, not back to resave the information.

One more thing-- in the frm_formname file, there is a small amount of
processing to change attributes.variables to wkVariables for all the form
fields involved, so we can repopulate the form when there is an error, or
when there is info coming out of the DB.  This processing could be moved out
to an act_file, but it is really tied to the frm_file exclusively.

Just another way to do it, without losing your data through a cflocation...

David Huyck
[EMAIL PROTECTED]

> although I don't use the cf_reuseform tag, the issue of non-JavaScript
form
> validation is one that affects most folks...
>
> The way I handle the issue is this:
> User visits form page
> Form field value defaults are determined by checking the values within
> db-based client variables (or you could use good ol' session variables)
> User submits form.
> Form results are stored in db-based client variables (or you could use
good
> ol' session variables), the same ones mentioned earlier
> Form validation routine is executed
> If form results are rejected, a CFLOCATION is done back to index.cfm, with
> the fuseaction being the one that invoked the form page in the first
place.
> Since the db-based client variables are now populated with values, these
are
> loaded up into the form, thus preserving the user's original submission.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to