PDA

View Full Version : [Resolved] Simple form Ext.getCmp returns "undefined"



bainsbury
3 Sep 2009, 8:22 AM
I am a newbie, but have scoured to solve a simple problem.

I have a custom validation routine to check two fields (for email reg) have the same contents. The call to Ext.getCmp returns undefiend, yet the field exists.

Code follows:


xt.apply(Ext.form.VTypes, {
fieldmatch : function(val, field) {
if (field.sisterField) {
var sisterfld = Ext.getCmp(field.sisterField);
return (val == sisterfld.getValue());
}
return true;
},
fieldmatchText : 'The two field entries must be the same'
});


Ext.onReady(function(){
Ext.QuickTips.init();

var form_employee = new Ext.form.FormPanel({
labelAlign: 'top',
title: 'Enter Two Fields',
width: 580,
items: [{
xtype:'textfield',
fieldLabel: 'Field1',
name: 'field1',
},{
xtype:'textfield',
fieldLabel: 'Confirm Field1',
name: 'field2',
vtype:'fieldmatch',
sisterField: 'field1',
}]
});

form_employee.render('hr-form-1');

});All guidance apprecaited

hendricd
3 Sep 2009, 9:33 AM
@bainsbury -- Pls, wrap your code fragments in [code/] tags in the future.

Ext.getCmp expects what? an id ! not a name.

Give your fields id's to start with, Ext will assert a name = id for you (unless you wish to override the name).

bainsbury
3 Sep 2009, 10:34 AM
DOH. Thanks Doug. Resolved in 2 seconds.