Ext JS - Learning Center

Manual:Forms:BasicForm

From Learn About the Ext JavaScript Library

Revision as of 22:07, 11 December 2008 by Jspeaks (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

When using 'SetValues' for form elements, an object array with id, value pairs is required similar to :

myform = new Ext.form.Form({
    labelWidth : 75
});
myform.add (
    new Ext.form.TextArea({
        fieldLabel : 'label for box 1',
        name : 'myfield1',
        height : 50
    })
);
myform.setValues([
    { id : 'myfield1', value : '123' },
    { id : 'myfield2', value : '456' }
]);

If you simply want to access the value of an items field from a buttons handler, you can use the following code:

var myform = new Ext.BasicForm({
	defaultType: 'textfield',
	items:[{
		 fieldLabel: 'Search',
		 name: 'search',
		 allowBlank:false
	 }],
	buttons:[{
		 text: 'Search',
		 handler  : function(){
			alert(this.ownerCt.getForm().findField('search').getValue());
		 }
	 }]
}