This question came over Twitter today so I thought I'd address it in a blog. User @brooksfolk asked if there was a way to get the original form field names sent to a ColdFusion file. When you look at form.fieldnames, or just cfdump the Form scope, the values are always uppercased. Consider the following simple form.

<form method="post"> <input type="text" name="naMe"><br/> <input type="text" name="AGE"><br/> <input type="text" name="foo"><br/> <input type="submit"> </form>

<cfdump var="#form#">

As you can see, each of my three fields uses a different mixture of upper and lower case names. But when I view the dump, I see this:

As you can see, everything is now uppercase. I had a hunch though that getHTTPRequestData might have the "real" data and indeed it does. Here is what a dump of that function shows:

Woot - as you can see - both the original form field names and values (which are blank in this case since I didn't bother to type anything in) are in the content key. If I actually type some values in, I get a more realistic version: naMe=cat+man&AGE=moo&foo=mooooo. This looks easy enough to parse. Here is what I came up with:

<cfset content = getHTTPRequestData().content> <cfset formMoreGooder = {}> <cfloop index="pair" list="#content#" delimiters="&"> <cfset name = listFirst(pair, "=")> <cfset value = urlDecode(listLast(pair, "="))> <cfset formMoreGooder[name] = value> </cfloop>

Basically I just treat the data as 2 sets of lists. Each pair is delimited by an ampersand and then each pair itself is split by the equal sign. The values are url encoded but luckily ColdFusion provides a way to reverse that. And here is the result...

Hope this is helpful to someone.