– Common Function Library Project

formToNameValuePairs(formStruct[, doNotProcessList])

Last updated June 18, 2009


Stephen Withington

Version: 0 | Requires: CF7 | Library: StrLib

Pass me a form and I'll generate url-friendly concatenated name-value pairs of each form field. If you want me to ignore any of the form fields, I can do that too!

Return Values:
Returns a string


<cfoutput>#formToNameValuePairs(form, "SUBMIT,ISSUBMITTED")#</cfoutput>


Name Description Required
formStruct form structure Yes
doNotProcessList List of fields to ignore No

Full UDF Source:

 I generate concatenated name-value pairs from forms.
 @param formStruct      form structure (Required)
 @param doNotProcessList      List of fields to ignore (Optional)
 @return Returns a string 
 @author Stephen Withington ( 
 @version 0, June 17, 2009 
<cffunction name="formToNameValuePairs" returntype="string" output="false" access="remote"
            hint="pass me a form and i'll generate concatenated name-value pairs.">

    <cfargument name="formStruct" type="struct" required="true" hint="the form struct to parse and concatenate" />
    <cfargument name="doNotProcessList" type="string" required="false" hint="a list of form fields to ignore" default="" />

    <cfset var local = structNew() />
    <cfset local.nameValuePairs = "" />
    <cfset local.doNotProcess = arguments.doNotProcessList />
    <cfset local.field = "" />

    <cfif structKeyExists(arguments,"formStruct") and structKeyExists(arguments.formStruct,"fieldnames")>
            <cfloop list="#arguments.formStruct.fieldnames#" index="local.field"> 
                <cfif not listFindNoCase(local.doNotProcess,local.field)>
                    <cfset local.doNotProcess = listAppend(local.doNotProcess,local.field) />
                    <cfset local.nameValuePairs = listAppend(local.nameValuePairs,lcase(local.field) & "=" & urlEncodedFormat(form[local.field], "utf-8"), "&") />                        

    <cfreturn local.nameValuePairs />    


Latest Additions

Raymond Camden added
November 04, 2017

Leigh added
May 11, 2016

Raymond Camden added
May 10, 2016

Kevin Cotton added
May 05, 2016

Raymond Camden added
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson