View Full Version : How to render a field from a config object by taking in account its xtype ?

17 Jun 2009, 4:20 AM
I want to create a form field out of a form, and I want to create it as a field object. I've a config object that represents it, and I want to convert it to a field object.
I've tried to do that:

field = new Ext.form.Field(config_object)
But this solution doesn't take in account the xtype stored in the config object. In fact, it generates a simple text field, even if the xtype of the field describe it as a combobox.
And I don't want to do a switch on each xtype to use the correct constructor in function of it...

Does someone knows how to do it?

17 Jun 2009, 4:24 AM

var field = Ext.ComponentMgr.create(config_object, 'textfield');
('textfield' is the xtype used when the config object doesn't contain an xtype)

17 Jun 2009, 4:40 AM
Thank you! It works perfectly!