• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFFORM bug

Explorer ,
May 26, 2010 May 26, 2010

Copy link to clipboard

Copied

I've picked up something weird (and a little bit irritating) with CFFORM in CF 8 and 9.

If you have two fields named x and x_date where x is any name e.g.

data, data_date or

measurement, measurement_date

and field x is cfinput type=text (but you use a number with a decimal)

and field x_date is cfinput type=datefield

then when this form is submitted, field x will be automatically reformatted as a date.

Sample code: create a page called data.cfm and copy this into it.

Click submit and watch variable [data] magically transform into a date.

There is an obvious workaround (just don't name your fields like this) but it took a while to figure this out.

-----------------------------------------------------------------

<cfparam name="data" default="1.2">
<cfparam name="data_date" default="#now()#">

<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<cfoutput>
<Cfform name="test" action="data.cfm">
<table>
<tr>
    <td>data</td>
    <td><cfinput type="text" name="data" value="#data#"></td>
</tr>
<tr>
    <td>data_date</td>
    <td><cfinput type="datefield" name="data_date" value="#dateformat(data_date,"yyyy/mm/dd")#" mask="dd-mmm-yyyy"></td>
</tr>
</table>
<input type="submit" />
</Cfform>
</cfoutput>

</body>
</html>

Views

426

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 26, 2010 May 26, 2010

Copy link to clipboard

Copied

LATEST

Yep, it's been that way for a long time. This page explains it:

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a7b.html

I avoid naming any of my form fields with the suffixes listed on that page.

Deb

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation