Date not being set correctly

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

PS: I’m using DHTMLX Suite v5 professional, and the back-end MySQL database is v5.5.41.

Thank you again!

Ajaxian

Please, try to add the following code to the init of your form:
form.getFormDataA = form.getFormData;
form.getFormData = function(){
form.getFormDataA(true)
}

Sematik, if you would reread my code up-thread, you’ll see there is no form ‘init’ method being called. The form is bound to a grid, which is turn is synced to a datastore.

But still, I tested placing your code first before and then after the form bind. It didn’t work in either case.

I would really appreciate another suggestion. Thanks!

Ajaxian

Could you please, provide with a complete demo, where the problem can be reconstructed locally, so the proper solution could be provided.
Here you can find a tutorial about creating a complete demo:
docs.dhtmlx.com/tutorials__auxi … pport.html

Please, refer to the following attached demo.
It works well for me.
If the problem still occurs for you please, provide with a similar complete demo, where the issue can be reconstructed
form_datastore.zip (1.41 KB)