Copy link to clipboard
Copied
Hello -
Has anyone ever seen CFDUMP - form, not display all the fieldnames with data in it?
I have a number of formfields, but not A LOT of them and one of the names is missing.
Anyway, I have attached a CFDUMP of the form fields...
The field in question should be the last one in the list, it should be journal_date.
It doesn't exist in the list of fieldnames, but the value does exist.
Anybody have an idea of what's happening?
Thanks
Doug
Not exactly reserved, but it's intended for use with CF's server-side validation. The field name "example_date" is used to ensure "example" is a date. There are a handful of these validation suffixes. They've been around since a very early version of CF - maybe 2.0?
Dave Watts, Eidolon LLC
Well, no. I did understand it completely, having read your note and Dave's before I replied.
I meant what I said, that the problem (of the field not being in the form.fieldnames) not happening for me except in cf10 (which would jive with the so post from so long ago). FWIW, I tested _date and _required. I didn't show code as it seemed everyone was on the same page.
So are you saying you tested things and confirm what he saw? As I asked him, I'll be curious what cf version and update that's
...Copy link to clipboard
Copied
Ok... I did some additional testing... I changed the fieldname from journal_date to journal_date1, and that was included in the form.fieldnames.
Does anyone know if journal_date is reserved?
Thanks
Doug
Copy link to clipboard
Copied
Not exactly reserved, but it's intended for use with CF's server-side validation. The field name "example_date" is used to ensure "example" is a date. There are a handful of these validation suffixes. They've been around since a very early version of CF - maybe 2.0?
Dave Watts, Eidolon LLC
Copy link to clipboard
Copied
I initially misunderstood the issue you describe. What I now understand is that journal_date is missing from the list form.fieldnames. If so, then it would seem that this is a bug. Unless, of course, ColdFusion reserves field names such as xxx_date for validation. See https://stackoverflow.com/questions/592076/value-missing-from-form-fieldnames-in-coldfusion
Copy link to clipboard
Copied
While Dave and BKBK are right about the explanation and workaround, I'll not that I tried this on all versions back to 10 (all at their latest available updates), and the problem you describe does not happen for me on any but cf10.
So i'm curious to hear what version you're on, and what update of that.
Copy link to clipboard
Copied
Charlie, I suspect that you misunderstand it as I, too, did initially. The issue is not about the form field xxx_date. It is about the list form.fieldnames.
Apparently, when a form field is named xxx_date, then that name is missing from the list form.fieldnames. This has been known for quite some time. The Stackoverflow link in my previous post points to a report of the issue over 15 years ago.
It is clear that, regarding form field names, ColdFusion treats words that end in _date as reserved words. In fact, the same goes for words ending in _integer ,_time ,_eurodate ,_range or _float, as the following demonstration shows.
That this has to do with validation is no surprise. The name endings, integer, time, date, etc., are among the values of the type attribute of the isValid function.
Demo:
<cfif structKeyExists(form, "fieldnames")>
<h2>
Field names in <i>form.fieldnames</i>
</h2>
<p>
<cfscript>
// The list form.fieldnames
fieldNamesList=form.fieldnames;
closure=function(item){
WriteOutput( item & "<br>"); // list each item on separate line
}
fieldNamesMap=listMap(fieldNamesList,closure);
</cfscript>
<h2>
Field names not in <i>form.fieldnames</i>
</h2>
<p>
<cfscript>
//The form fields not in form.fieldsname
closure=function(key, value){
if (!listContainsNoCase(fieldNamesList, key)){
// list on separate line each not in fieldNamesList
WriteOutput( key & "<br>");
}
}
formFieldsMap=structMap(form,closure);
</cfscript>
</p>
<cfelse>
<p>
<cfoutput><form action="#cgi.script_name#" method="post"></cfoutput>
xxx_array: <input type="text" name="xxx_array"><br>
xxx_boolean: <input type="text" name="xxx_boolean"><br>
xxx_creditcard: <input type="text" name="xxx_creditcard"><br>
xxx_date: <input type="text" name="xxx_date"><br>
xxx_eurodate: <input type="text" name="xxx_eurodate"><br>
xxx_email: <input type="text" name="xxx_email"><br>
xxx_float: <input type="text" name="xxx_float"><br>
xxx_guid: <input type="text" name="xxx_guid"><br>
xxx_integer<input type="text" name="xxx_integer"><br>
xxx_numeric<input type="text" name="xxx_numeric"><br>
xxx_query: <input type="text" name="xxx_query"><br>
xxx_range: <input type="text" name="xxx_range"><br>
xxx_regex: <input type="text" name="xxx_regex"><br>
xxx_ssn: <input type="text" name="xxx_ssn"><br>
xxx_string: <input type="text" name="xxx_string"><br>
xxx_struct: <input type="text" name="xxx_struct"><br>
xxx_telephone: <input type="text" name="xxx_telephone"><br>
xxx_time: <input type="text" name="xxx_time"><br>
xxx_uuid: <input type="text" name="xxx_uuid"><br>
xxx_usdate: <input type="text" name="xxx_usdate"><br>
xxx_xml: <input type="text" name="xxx_xml"><br>
xxx_zipcode: <input type="text" name="xxx_zipcode"><br>
<br><input type="submit" name="submitForm" value="submit">
</form>
</p>
</cfif>
<cfdump var="#form#" >
Result:
On the subject of form field names, there is yet another curiosity. ColdFusion treats words that end in _required as reserved words.
Copy link to clipboard
Copied
Well, no. I did understand it completely, having read your note and Dave's before I replied.
I meant what I said, that the problem (of the field not being in the form.fieldnames) not happening for me except in cf10 (which would jive with the so post from so long ago). FWIW, I tested _date and _required. I didn't show code as it seemed everyone was on the same page.
So are you saying you tested things and confirm what he saw? As I asked him, I'll be curious what cf version and update that's on.
Copy link to clipboard
Copied
The demo in my last post was done on ColdFusion 2023 Update 7. To repeat, the result was that the following names were missing from the form.fieldnames list:
xxx_eurodate
xxx_integer
xxx_range
xxx_float
xxx_time
xxx_date
Copy link to clipboard
Copied
And I'll repeat that I did not experience that with CF2023 (or earlier) back to CF11, only in CF10. Here is the simple code I was using:
<form action="" method="post">
<input type="text" name="my_date" value="test"><br>
<input type="submit">
</form>
<cfif cgi.request_method is "post">
<cfdump var="#form#">
</cfif>
Is serversideformvalidation enabled? <cfoutput>#getApplicationMetadata()["serversideformvalidation"]#</cfoutput>
<br>
CF version: <cfoutput>#server.coldfusion.productversion#</cfoutput>
And here is the application.cfc, and is seems not to matter what the setting is (note that I show in code above outputting it, to confirm the setting):
<cfcomponent>
<cfset this.serversideformvalidation=true>
</cfcomponent>
Here is the output I get (on submission of the form) in CF2023:
Do you get something different?
Copy link to clipboard
Copied
Hmmm, if the submit form field has a name attribute, then my_date will not appear in the form.fieldnames list:
<form action="" method="post">
my1st_date:<input type="text" name="my1st_date" value="test1"><br>
my2nd_date:<input type="text" name="my2nd_date" value="test2"><br>
my3rd_date:<input type="text" name="my3rd_date" value="test3"><br>
<br><input type="submit" name="submitForm" value="submit">
</form>
<cfif cgi.request_method is "post">
<cfdump var="#form#">
</cfif>
The result:
Copy link to clipboard
Copied
Let's go one step further: an all-in-one demo
<form method="post">
xxx_date: <input type="text" name="xxx_date" value="x"><br>
xxx_eurodate: <input type="text" name="xxx_eurodate"value="x"><br>
xxx_float: <input type="text" name="xxx_float" value="x"><br>
xxx_integer<input type="text" name="xxx_integer"value="x"><br>
xxx_range: <input type="text" name="xxx_range"value="x"><br>
xxx_time: <input type="text" name="xxx_time"value="x"><br>
<p>
<!--- Named submit field--->
<input type="submit" name="sbmt_btn" value="Send Using Named Submit Button"><br>
<!--- Unnamed submit field--->
<input type="submit">
</p>
</form>
<cfif cgi.request_method is "post">
<cfdump var="#form#">
</cfif>
Result: