Manual:Forms:BasicForm (Legacy)

This version of our Learning Center is unmaintained.
This article may be out-of-date or contain incorrect information.
Please visit the new Sencha Learning Center for up-to-date material.

Go to the new Sencha Learning Center

From Sencha - Learn

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());
		 }
	 }]
}
This page was last modified on 11 December 2008, at 22:07. This page has been accessed 29,911 times.