How to initialize a Date field to today's date?
10 posts
• Page 1 of 1
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
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(){ Hope this helps a little. -Steve
Re: How to initialize a Date field to today's date?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?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?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?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"? Last edited by neotrode on Mon Dec 20, 2010 11:19 am, edited 1 time in total.
Re: How to initialize a Date field to today's date?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?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!
10 posts
• Page 1 of 1
Who is onlineUsers browsing this forum: No registered users and 0 guests |