View Full Version : Accessing the scope of a form stored in a variable with Ext.create

14 Jul 2014, 5:51 AM
I built a form using the following method

var myform = Ext.create('Ext.form.Panel', options);

where the options variable is a huge object with form elements including this textfield

fieldLabel : 'bName',
id :'bname',
itemId :'bname',
name : 'bname',
xtype : 'textfield'

However whenever I try to access the textfield with Ext.get(), it returns null

options = {... //extensive form fields ...}
var myform = Ext.create('Ext.form.Panel', options);
console.log(Ext.get('bname')); //returns null

How can I access the scope of bname so I can execute the Ext.get() function?

Phil Guerrant
14 Jul 2014, 8:49 AM
Ext.get() will find an Ext.dom.Element with the given id. If your component is not yet rendered it will have no Element and Ext.get() will return null.

To get a reference to the component use Ext.getCmp()