Results 1 to 3 of 3

Thread: [Resolved] Simple form Ext.getCmp returns "undefined"

  1. #1

    Question [Resolved] Simple form Ext.getCmp returns "undefined"

    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:
    Code:
    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
    Last edited by hendricd; 3 Sep 2009 at 9:34 AM. Reason: Added [code/] tags (so we can read it)!

  2. #2
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Default

    @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).
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  3. #3

    Default

    DOH. Thanks Doug. Resolved in 2 seconds.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •