Change to allow NULLs for datetime properties

Description

Recently I've been having some problems with the "datetime" formtool which defaults to adding 200 years when you hide it (by unchecking the checkbox) in the object admin screen.

I had a look and made a couple of small changes which seem to work of for me in my environment, note that I haven't tested in MSSQL.

Basically in /farcry/core/tags/navajo/objectStatus.cfm I added a small change to see if the property was a date and wasn't required (as defined by the cfproperty metadata), don't set a default date...instead just an empty string.

Also in packages/formtools/datetime.cfc I've made a couple of changes to prevent JS from adding 200 years as the default date. Note that if your property metadata says the field is required, the default behaviour still applies which is to "pass" validation and set a date value of now()+200. I suppose ideally this should "fail" instead of pass though.

This all comes together due to some code inside generateSQLNameValueArray() (DBGateway.cfc) which sets a null for dates when there isn't a date:

<cfif IsDate(propertyValue)>
<cfset stField.cfsqltype = "CF_SQL_TIMESTAMP" />
<cfset stField.value = propertyValue />
<cfelseif tableDef[field].nullable>
<cfset stField.value = "NULL" />
<cfelse>
<cfabort showerror="Error: #field# must be a date (#propertyValue#).">
</cfif>

I'll try to attach these 2 files for review after creating the ticket, I hope they're ok.

Environment

ColdFusion 8 (developer) Mac OSX Apache 2+ MySQL 5

Attachments

2

Activity

Show:
Matthew Bryant
March 2, 2010 at 4:22 AM

empty (null) dates can now be stored in farcry. Let the pigeons loose.

Fixed

Details

Assignee

Reporter

Fix versions

Priority

Created June 1, 2009 at 7:11 AM
Updated March 2, 2010 at 4:22 AM
Resolved March 2, 2010 at 4:22 AM