PDA

View Full Version : [CLOSED] Ext.form.Field.onRender refactoring.



WixSL
19 Dec 2010, 3:49 PM
The Ext.form.Field.onRender method is ugly to override since if you want to call the parent method you have to copy the entire code to do so.
Could the red code below at least be moved to another method?



Ext.form.Field.onRender: function(ct, position){
if(!this.el){
var cfg = this.getAutoCreate();

if(!cfg.name){
cfg.name = this.name || this.id;
}
if(this.inputType){
cfg.type = this.inputType;
}
this.autoEl = cfg;
}

Ext.form.Field.superclass.onRender.call(this, ct, position);
if(this.submitValue === false){
this.el.dom.removeAttribute('name');
}
var type = this.el.dom.type;
if(type){
if(type == 'password'){
type = 'text';
}
this.el.addClass('x-form-'+type);
}
if(this.readOnly){
this.setReadOnly(true);
}
if(this.tabIndex !== undefined){
this.el.dom.setAttribute('tabIndex', this.tabIndex);
}

this.el.addClass([this.fieldClass, this.cls]);
}


Thank you.

Condor
19 Dec 2010, 10:58 PM
Why? You have the option of either creating your own 'el', specify defaultAutoCreate or autoCreate or even override getAutoCreate.

(and in Ext 4 this will be totally different anyway, because of the complete Form/Field restructure)

WixSL
20 Dec 2010, 8:00 AM
Because i want to modify only the red code, but you are right, i could use defaultAutoCreate.
Thanks for the help.