Page 1 of 1

PostPosted: Wed Apr 04, 2007 3:45 am
by rbchen
I have a DB column defined as Date. Quick Forms renders it as a text field with the Calender picker. Since I am not allow to use mySQl function to set the default date for the column, how do I set it to today's date in the "New Record" page?

Many thanks in advance for any insight!!

Raymond

PostPosted: Thu Apr 05, 2007 10:48 am
by shannah

Hi Raymond,

There are a couple of choices here.Ê If all you want is to have the column act sort of like a timestamp, you can use the timestamp parameter in the fields.ini file:

http://framework.weblite.ca/documentation/manual/fields_ini/field_timestamp

Alternatively you can set the default value using the %fieldname%__default() method in the delegate class:

e.g.

function mydatecol__default(){
ÊÊÊ return date('Y-m-d');
}



Hope this helps a little.

-Steve


PostPosted: Thu Apr 05, 2007 2:13 pm
by rbchen
Thanks Steve! It works.

Raymond

Re: How to initialize a Date field to today's date?

PostPosted: Wed Aug 11, 2010 1:47 pm
by mikep
I added the function to the table's delegate class:

function mydatecol__default(){
return date('Y-m-d');
}

but the field is populated with 0000-00-00. Did I do something incorrectly?

Mike

Re: How to initialize a Date field to today's date?

PostPosted: Wed Aug 11, 2010 2:05 pm
by shannah
That snippet assumes that your date field is named mydatecol. You should substitute the field name for 'mydatecol'.
-Steve

Re: How to initialize a Date field to today's date?

PostPosted: Sat Aug 14, 2010 10:08 am
by mikep
I substituted the actual name of the column for mydatecol. When I do that, the default is 0000-00-00. Without this function, there is no default.

Mike

Re: How to initialize a Date field to today's date?

PostPosted: Mon Dec 20, 2010 11:10 am
by neotrode
Unfortunately, Shannah's link doesn't exist anymore. Can someone please point me to the replacement link?

Also, I looked into Deligating a program.php as per the docs. However, how can I make that specific to the particular website? It appears that Xataface simply creates a two file installation containing a config.ini and an index.php file. Then it refers to the main installation of Xataface. If I make a website under folder "test-site" and have the two created files point to the Xataface directory, how do I isolate the program.php file to only perform for the "test-site"?

Re: How to initialize a Date field to today's date?

PostPosted: Mon Dec 20, 2010 11:18 am
by shannah

Re: How to initialize a Date field to today's date?

PostPosted: Mon Dec 20, 2010 11:21 am
by neotrode
Nice! Sounds easy enough and specific to the website installation in question. I will give a it a shot. Thank you for the exceptionally speedy reply.

Re: How to initialize a Date field to today's date?

PostPosted: Mon Dec 20, 2010 11:30 am
by neotrode
Perfect! Thanks. I also understand how to isolate the configuration. I overlooked the example stating to create subfolders like "tables" in the website in question. That did it!