Datepicker default value on form


#1

I have a request.
Can you add or create a method to automatically fill the datepicker value when initiated via form instance?

Example:

var formStruct = [
  {
   type: 'calendar', name: 'hiredate', dateFormat: '%m/%d/%Y',
  } 
];

var _form = new dhtmlXForm("container_id",  formStruct);

The above snippet works but I want to have a method in the calendar input that automatically fills the date base on the clients system date. See snippet below.

var formStruct = [
  {
   type: 'calendar', name: 'hiredate', dateFormat: '%m/%d/%Y',
   defaultFill: true
  } 
];

Right now what I am doing is after initiating the form I have to write few lines to fill the empty datepicker something like .

 _form.setItemValue("hiredate", moment().format('MM/DD/YYYY'));

That solves my problem but I adds few kb in script. We can automate the filling of date right?

How to do it automatically? Or how can I extend the functionality of dhtmlx calendar so I can add this custom method.

I hope this kind of feature also present in the dhtmlx version 6+ that would be nice.


#2

Please, try to define a value in the calendar item in your form structure:

var formStruct = [
  {
   type: 'calendar', name: 'hiredate', dateFormat: '%m/%d/%Y', value: "01/01/2016", // set the required value
   defaultFill: true
  } 
]