Every two years I have to create a web form for people to submit online nominations for transportation awards. Every time I create it, I think I'll be able to reuse it the next time, but too much ends up changing (the questions, security requirements, etc) that I end up having to do more than half of it over.
The form has JS validation for all fields for data type, max length, etc, but it also has serverside validation. If you submit the form with JS disabled and there's an error, the form reloads (populated with the data you just entered) and displays error messages telling you what's wrong, so you can edit the data and resubmit.
It's a large form, so I don't want to have more than one copy of it, so my single copy has to:
1) Be a new (blank) form.
2) Be the form that gets populate from the database when people want to edit their existing nomination.
3) Retain the information that someone just entered when there's an error.
The way I've been doing this is to <cfparam> all the FORM data then do this for the values of all the inputs:
value="#iif(FORM.nominator_org neq "",DE(FORM.fieldname),DE(query.fieldname))#"
If the FORM variable has a value, use it, otherwise use the value from the query. Needless to say, this is a bit clunky, so I was wondering if there was a cleaner way. There are over 40 fields, so it ends up being a lot of code!