Hi,
I'm using a date spinner editor to set the date in a field on a formview. This is working fine, but I need the capability of entering a date without a month or day. For example, for the date of manufacture field, the user can enter just a year or just a year and month.
I can add a blank day to the day spinner static data, and I can add a blank month to the month spinner static data. However, in the editor properties, I need to modify the javascript for the "set value in editor" code to accept a null value for a day (eg 00/04/2018) or null value for both day and month (00/00/2018). Below is the code, but I can't work out what I need to change. Would welcome any help from js gurus.
I'm using a date spinner editor to set the date in a field on a formview. This is working fine, but I need the capability of entering a date without a month or day. For example, for the date of manufacture field, the user can enter just a year or just a year and month.
I can add a blank day to the day spinner static data, and I can add a blank month to the month spinner static data. However, in the editor properties, I need to modify the javascript for the "set value in editor" code to accept a null value for a day (eg 00/04/2018) or null value for both day and month (00/00/2018). Below is the code, but I can't work out what I need to change. Would welcome any help from js gurus.
Code:
if(typeof {dialog.object}._functions.setDaysInMonth_EDITOR_DATE == 'undefined') { {dialog.object}._functions.setDaysInMonth_EDITOR_DATE = function() { //read year and month from the corresponding spinner and then figure out how many days are in that year/mont var sYear = {dialog.object}.getControl('EDITOR_DATE_S_YEAR'); var sMonth = {dialog.object}.getControl('EDITOR_DATE_S_MONTH'); var sDate = {dialog.object}.getControl('EDITOR_DATE_S_DAY'); if(!sYear || !sMonth || !sDate) return false; var year = sYear.value; var month = sMonth.value; //day is 1 based, month is 0 based. setting the day to 0 gives last day of previous month var dInM = new Date(Number(year),Number(month), 0).getDate(); var dates = []; dates.push({html: ' ', value: '0'}); for(var i=1;i<=dInM;i++) dates.push({html: i, value: i}); if(sDate.value > dInM) sDate.value = dInM; sDate.populate(dates,true); sDate.refresh(); } } var sDate = {dialog.object}.getControl("EDITOR_DATE_S_DAY"); var sMonth = {dialog.object}.getControl("EDITOR_DATE_S_MONTH"); var sYear = {dialog.object}.getControl("EDITOR_DATE_S_YEAR"); var d = new Date(); //get the date format of the data in the form (must be the format in which the data is stored - not displayed) var dfmt = A5.serverSideDateFormat; if(value != null) d.fromFormat(value,dfmt); sYear.refresh(); sMonth.refresh(); sYear.setValue(d.getFullYear()); sMonth.setValue(d.getMonth()+1); if(value == '') { sYear.setValue('0'); sMonth.setValue('0'); } {dialog.object}._functions.setDaysInMonth_EDITOR_DATE(); if(value != '') { sDate.setValue(d.getDate()); } else { sDate.setValue('0'); }
Comment