Hello,
I have a calendar field (‘resubmitDate’) within a form (‘bForm’), which is in turn attached to a layout. The calendar field is defined like this:
{type: "calendar", rows: 0, inputWidth: 150, name: "resubmitDate", label: "Resubmit Date", value: "", dateFormat: "%Y-%m-%d", serverDateFormat: "%Y-%m-%d", weekStart: "7", enableTodayButton: true, readonly: false, required: false}
The form uses a datastore, defined like this:
abDataStore = new dhtmlXDataStore({
url: "prMain.php",
datatype: "xml"
});
to read from and write to a back-end MySQL database.
A dataprocessor is also used with the datastore, and is defined like this:
abDataProcessor = new dataProcessor("prMain.php");
abDataProcessor.init(abDataStore);
The back-end SQL code looks like this:
$data->render_sql("SELECT ...
, resubmitDate ...
FROM prMain_tbl ...
with the ‘resubmitDate’ column defined as datatype DATE.
The calendar control displays nicely, and when a resubmit date is selected from it, the date shows on the form in the correct yyyy-mm-dd format. However, when the date is saved to the back-end database, using bForm.save(), the value stored is ‘0000-00-00’. When I display the selected resubmit date from the calendar control using alert(resubmitDate.getDate());, it shows ‘Fri Jan 20 2017 16:05:00 GMT-0800 (Pacific Standard Time)’. I’d expect it to show ‘2017-01-20’ and for that value to be stored in the database.
Please, let me know the correct way for the date to be stored in the database from the calendar/form. Thank you!
Ajaxian