Highlighted

<cfinput type="datefield"> question

New Here ,
Jan 21, 2019

Copy link to clipboard

Copied

Is it possible to pass a value to a datefield cfinput?

I have an edit form that is auto filled from a database - I can fill text fields by passing value to them.  I tried value and default in the type="datefield" and it doesn't seem to work.

<cfset ThisDate= "2016/01/20">

<cfform id="Add" name="Add" method="post" action="UpdateDonation.cfm" >

     <cfinput name="test" type="text" value="#ThisDate#"> <--- Works but no date picker

     <cfinput name="test" type="text" mask="yyyy/mm/dd" default="#ThisDate#"> <--- date picker, but no date prefilled

     <cfinput name="test" type="datefield" mask="yyyy/mm/dd" default="#ThisDate#"> <---- Gives error

</cfform>   

What am I doing wrong?

Thanks!

Views

219

Likes

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

<cfinput type="datefield"> question

New Here ,
Jan 21, 2019

Copy link to clipboard

Copied

Is it possible to pass a value to a datefield cfinput?

I have an edit form that is auto filled from a database - I can fill text fields by passing value to them.  I tried value and default in the type="datefield" and it doesn't seem to work.

<cfset ThisDate= "2016/01/20">

<cfform id="Add" name="Add" method="post" action="UpdateDonation.cfm" >

     <cfinput name="test" type="text" value="#ThisDate#"> <--- Works but no date picker

     <cfinput name="test" type="text" mask="yyyy/mm/dd" default="#ThisDate#"> <--- date picker, but no date prefilled

     <cfinput name="test" type="datefield" mask="yyyy/mm/dd" default="#ThisDate#"> <---- Gives error

</cfform>   

What am I doing wrong?

Thanks!

Views

220

Likes

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
Jan 21, 2019 0
Adobe Community Professional ,
Jan 21, 2019

Copy link to clipboard

Copied

I'd recommend against using CF's built-in "rich" data formats, just because they're going to be more fragile than using your own JavaScript over time. That said, have you tried formatting the date using parseDateTime before sticking it in the field?

Dave Watts, Eidolon LLC

Likes

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
Reply
Loading...
Jan 21, 2019 0
LEGEND ,
Jan 22, 2019

Copy link to clipboard

Copied

I have to agree with Dave.  Do not use CFFORM or any related elements.  They were a good idea when first introduced, but the Ext.js and other libraries that CFFORM relies on are seriously out of date (last I checked) and don't work all that well.  You'd be much better off using your own vanilla JavaScript or jQuery/MooTools libraries and coding it all that way if you're looking for binding and such.

If you are using CFFORM for the Flash forms, don't.  Just.. don't.  Flash is dying and will soon no longer be supported in any browser.  Before you know it, your form will be obsolete.

Just my two cents.

V/r,

^ _ ^

Likes

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
Reply
Loading...
Jan 22, 2019 0
Adobe Community Professional ,
Jan 22, 2019

Copy link to clipboard

Copied

thanesherrington  wrote

Is it possible to pass a value to a datefield cfinput?

I have an edit form that is auto filled from a database - I can fill text fields by passing value to them.  I tried value and default in the type="datefield" and it doesn't seem to work.

<cfset ThisDate= "2016/01/20">

<cfform id="Add" name="Add" method="post" action="UpdateDonation.cfm" >

     <cfinput name="test" type="datefield" mask="yyyy/mm/dd" default="#ThisDate#"> <!---- Gives error--->

</cfform>   

What am I doing wrong?

To answer your question, you are doing nothing wrong. Some recent ColdFusion updates omitted the underlying script that runs the calendar widget. Your ColdFusion version might be one of them.

You will find suggestions on how to fix <cfinput type="datefield"> in Charlie Areharts blog. Nevertheless, heed the advice from Dave Watts and WolfShade.

Likes

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
Reply
Loading...
Jan 22, 2019 0
Adobe Community Professional ,
Jan 23, 2019

Copy link to clipboard

Copied

Thane  without taking away the value of the other replies so far, I'll ask more simply the following, in order of likelihood to give you your solution:

- why are you using DEFAULT rather than VALUE?

- you say you got an error  What error?

- what do you see if you hardcode a value for the date?

- what do you see if you setup a simple 3-line test page  with just cfform and cfinput datefield and a hard-coded date?

/Charlie (server troubleshooter, carehart.org)

Likes

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
Reply
Loading...
Jan 23, 2019 0
New Here ,
Jan 24, 2019

Copy link to clipboard

Copied

https://forums.adobe.com/people/Charlie+Arehart  wrote

Thane  without taking away the value of the other replies so far, I'll ask more simply the following, in order of likelihood to give you your solution:

- why are you using DEFAULT rather than VALUE?

- you say you got an error  What error?

- what do you see if you hardcode a value for the date?

- what do you see if you setup a simple 3-line test page  with just cfform and cfinput datefield and a hard-coded date?

I tried Value, and it didn't work, and I saw in my reading that Default is an option, so I tried that

I'm using CFFiddle to test it here: https://cffiddle.org/app/file?filepath=f70bf3da-bb84-43fc-a1c1-fe72416e27c1/6e2f5bf6-6173-48db-868f-...

You can see the error there (it's a long server error).

What I want is: a)fill the field with the date from the query, and b)have the calendar open to that date when someone clicks it to select a new date.  It appears that neither of these things are possible (or at least I can't figure them out).

It also appears (extremely unfortunately) that anything beyond the base functionality is broken.  I was hoping that at this point (I've been away from CF for a few years and only used the base things for my personal projects) that by now CF would be more mature and their fancier tags (like cfform) would work properly.

I'll go back to writing my own javascript I guess.  Thanks to everyone for their answers.  I really appreciate you taking the time.

Likes

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
Reply
Loading...
Jan 24, 2019 0