Skip to content

Instantly share code, notes, and snippets.

@bcswartz
Created November 24, 2017 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcswartz/bb967e641f4cb315cf3b2943f7c71ba2 to your computer and use it in GitHub Desktop.
Save bcswartz/bb967e641f4cb315cf3b2943f7c71ba2 to your computer and use it in GitHub Desktop.
A method for performing processing on form field values defined in a list
<cffunction name="collectFormDataAndTrim" access="public" returntype="void" output="false" hint="I collect the form values">
<cfargument name="event" type="any">
<cfset var loc= StructNew()>
<cfset loc.propertyList= arguments.event.getArgument("propertyList","")>
<cfif loc.propertyList EQ "">
<cfset loc.propertyList= arguments.event.getValue("fieldnames")>
</cfif>
<cfset loc.form= StructNew()>
<cfloop index="loc.prop" list="#loc.propertyList#" delimiters=",">
<cfset loc.propValue= arguments.event.getValue(loc.prop)>
<cfif IsNumeric(loc.propValue)>
<cfset loc.form[loc.prop]= loc.propValue>
<cfelse>
<cfset loc.form[loc.prop]= Trim(HTMLEditFormat(beans.miscService.removeMSWordChars(loc.propValue)))>
</cfif>
</cfloop>
<cfset arguments.event.setValue("form",loc.form)>
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment