PDA

View Full Version : enable HtmlEditor marking invalid



rainchen
20 Feb 2009, 8:12 AM
The API said so:
Note: The focus/blur and validation marking functionality inherited from Ext.form.Field is NOT supported by this editor.

But I found it's not so hard to accomplish.


Ext.override(Ext.form.HtmlEditor, {
markInvalid: function(msg){
if(!this.rendered || this.preventMark){
return;
}
msg = msg || this.invalidText;
switch(this.msgTarget){
case 'qtip':
this.iframe.qtip = msg;
this.iframe.qclass = 'x-form-invalid-tip';
Ext.get(this.iframe).addClass(this.invalidClass);
break;
}
return Ext.form.TextArea.superclass.markInvalid.call(this, [msg]);
},
clearInvalid: function(){
if(!this.rendered || this.preventMark){
return;
}
switch(this.msgTarget){
case 'qtip':
this.iframe.qtip = '';
Ext.get(this.iframe).removeClass(this.invalidClass);
break;
}
return Ext.form.TextArea.superclass.clearInvalid.call(this);
}
});


Well, there is a little bug while changing from DesignMode to sourceEditMode then changing back to DesignMode, the background is gone. But I think it is alreay good enough in my case.