PDA

View Full Version : field.getName() only returns name if rendered



mdissel
23 May 2007, 12:26 AM
Hello

The current implementation of getName() only returns the name property if the field is rendered..

getName: function(){
return this.rendered && this.el.dom.name ? this.el.dom.name : (this.hiddenName || '');
},

I run into this problem when using the findField(name) before the form is rendered.

I think getName() should always return the name if the name is explicitly set.



getname: function(){
if (this.rendered && this.el.dom.name){
return this.el.dom.name;
}
var cfg = this.getAutoCreate();
return cfg.Name || this.name || this.hiddenName || '';
}


Thanks

Marco

jack.slocum
23 May 2007, 7:28 AM
That's a pretty expensive operation to find out the name. Can I ask what you are trying to do? - there has to be a better alternative.

mdissel
23 May 2007, 10:09 AM
I'm creating several dynamic Form Objects to be used inside a "wizard" control (a center ContentPanel with hidden tabs). I render the forms the first time the tab is being shown..

Initialy i created my forms only with a name field and not with an id..

During the creation of my form i want to catch some events on several fields. I use the FindField(..) to get a reference to my field and run into the problem of field.getName()

ps I could also use a local var to attach the events. but i was wondering why the findField(..) didn't work..

Thanks

Marco

jack.slocum
23 May 2007, 1:22 PM
How about using an id instead? This would be an instant lookup.

mdissel
23 May 2007, 11:34 PM
that's what i'm using right now ..;)