On/Off time(datetime field) doesn't cleared after cancel button is pressed | Adobe Higher Education
Skip to main content
yaraslaud208334
Level 2
October 16, 2015
Besvarat

On/Off time(datetime field) doesn't cleared after cancel button is pressed

  • October 16, 2015
  • 3 svar
  • 1332 visningar

HI,

I opened page properties and filled some fields

filled properties

After I pressed cancel button, and reopened properties dialog, all field cleared, but datetime fields didn't.

reopend dialog

What is the rigth way to clear datetime fields?

Thanks.

Det här ämnet har stängts för svar.
Bästa svar av yaraslaud208334

I was debuggin and find out strange behavior of  isApplyDefault method in \ibs\cq\ui\widgets\source\ext\override\widgets\form\Field.js. It is compare created and modefied date, if they equals returns true, otherwise false.

I just ovveride method processRecord in DateTime.js to remove calling isApplyDefault:

processRecord: function(record, path) { if (this.fireEvent('beforeloadcontent', this, record, path) !== false) { var v = record.get(this.getName()); if (v == undefined && this.defaultValue != null) { this.setValue(this.defaultValue); } else { this.setValue(v); } this.fireEvent('loadcontent', this, record, path); } }

in Field.js it is: 

processRecord: function(record, path) { if (this.fireEvent('beforeloadcontent', this, record, path) !== false) { var v = record.get(this.getName()); if (v == undefined && this.defaultValue != null) { if (this.isApplyDefault(record, path)) { this.setValue(this.defaultValue); } } else { this.setValue(v); } this.fireEvent('loadcontent', this, record, path); } }

3 svar

smacdonald2008
Level 10
October 16, 2015

See the API reference for a DateTime Object:

http://docs.adobe.com/docs/en/cq/5-6/widgets-api/index.html?class=CQ.form.DateTime

If the out of the box xtype is not clearing the way you want - write a custom xtype that uses a DateTime object. Then on the open event of the dialog - call SetValue and pass an empty value - which will clear the field. Then you can set new values each time you open the dialog. 

yaraslaud208334
yaraslaud208334SkribentSvar
Level 2
October 16, 2015

I was debuggin and find out strange behavior of  isApplyDefault method in \ibs\cq\ui\widgets\source\ext\override\widgets\form\Field.js. It is compare created and modefied date, if they equals returns true, otherwise false.

I just ovveride method processRecord in DateTime.js to remove calling isApplyDefault:

processRecord: function(record, path) { if (this.fireEvent('beforeloadcontent', this, record, path) !== false) { var v = record.get(this.getName()); if (v == undefined && this.defaultValue != null) { this.setValue(this.defaultValue); } else { this.setValue(v); } this.fireEvent('loadcontent', this, record, path); } }

in Field.js it is: 

processRecord: function(record, path) { if (this.fireEvent('beforeloadcontent', this, record, path) !== false) { var v = record.get(this.getName()); if (v == undefined && this.defaultValue != null) { if (this.isApplyDefault(record, path)) { this.setValue(this.defaultValue); } } else { this.setValue(v); } this.fireEvent('loadcontent', this, record, path); } }
smacdonald2008
Level 10
October 16, 2015

Nice observation - thank you for letting us know what you did.