Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8020583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:43:52+00:00 2026-06-04T21:43:52+00:00

I’m looking for the best way to structure form handling in a Coldfusion8 site

  • 0

I’m looking for the best way to structure form handling in a Coldfusion8 site I inherited.

There are a number of forms which relate to certain interactions, such as “user interactions” (register/login/logout/update). I have set up a global form/validation handler along this example, which works ok.

I have changed the setup a little and since I’m in my first months of working with Coldfusion I’d like to know, if the following way of handling things makes sense:

In my application.cfc I’m declaring session defaults for all “user interaction forms” like so:

<cffunction name="onSessionStart" returnType="boolean" output="false" hint="session initalizer">
    ...
    Session.FormData.User = {
        username="", 
        password="", 
        iln="", 
        companyname="",
        address="",
        ...
        formsubmitted=""
        }
</cffunction>

The idea was to setup defaults for all form fields, so I’m always submitting a “full form”, no matter whether the user simply logs in or registers.

Then inside my user-form-handler.cfc I’m declaring validation criteria:

 <cfcomponent extends="controllers.form_switch" output="false" hint="Utility for handling all user-related forms">     
    <cfscript>
        <!--- declare validation methods --->
        VARIABLES.Instance.Validation = {
            username = "string|len_6", 
            password="string|len_6",
            iln="spec_iln",
            ...
            companyname="string",
            address="string",
            formsubmitted="pass"
            }
        <!--- grab default values from Session --->
        VARIABLES.Instance.FormData = SESSION.FormData.User;
     </cfscript> 

     <!--- SET FORM DATA --->
     <cffunction name="SetFormData" access="public" returntype="void" output="false">
        <cfargument name="FormData" type="struct" required="true" hint="Form data" />
            <!--- overwrite default values with values passed in form submisson. --->
            <cfset VARIABLES.Instance.FormData = ARGUMENTS.FormData />
        <cfreturn />
    </cffunction>

    <!--- PROCESS --->
    <cffunction name="Process" access="remote" returntype="struct" output="false" hint="Process">

        <cfset var LOCAL = {} />
        <cfset LOCAL.Response = { Success = true, Errors = [], Data = "" } />
        <!--- call setFormData to overwrite defaults with submitted values --->
        <cfif IsStruct( ARGUMENTS[ 1 ] )>
            <cfset THIS.SetFormData( ARGUMENTS[ 1 ] ) />
        <cfelse>                
            <cfset THIS.SetFormData( ARGUMENTS ) />             
        </cfif> 
        ... validation/commit
        <cfreturn LOCAL.Response />
    </cffunction>

Whenever I submit a user related form, I’m submitting to the PROCESS function inside user-form-handler.cfc, which overwrites the session default values set inside SETFORMDATA and then validates the form fields before commiting to the database and returning the response object.

My Question:
While this works, I’m not sure about declaring default values for all form inputs inside onSessionstart inside my Application.cfc. Is there a better way to do this, when I want to run all user related form submits through this central handler?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:43:53+00:00Added an answer on June 4, 2026 at 9:43 pm

    If you aren’t changing any of the form submission defaults anywhere along the line (such as setting a form variable indicating the landing page along with google search terms or anything else that would change those variables to be something other than blank) you can just accept the blank fields and/or declare the defaults in the processing .cfc. I usually have a function that “pads out” missing fields and sets defaults. Then a separate function that validates the data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.