Results 1 to 3 of 3

Thread: Ext.FormPanel Button Question

  1. #1

    Default Ext.FormPanel Button Question

    Hello,

    Was wondering if there is any better way to get the basic form back in the following example without having to use Ext.getCmp() on the button handler?

    Code:
        {
            title: 'Login',
            width: 400,
            items: {
                xtype: 'form',
                id: 'login-form',
                defaults: {
                    anchor: '95%',
                    allowBlank: false
                },
                items: [ {
                    xtype: 'textfield',
                    fieldLabel: 'Email',
                    vtype: 'email'
                }, {
                    xtype: 'textfield',
                    fieldLabel: 'Password',
                    inputType: 'password'
                }, {
                    xtype: 'checkbox',
                    boxLabel: 'Remember Me'
                } ],
                buttons: [ {
                    text: 'Login',
                    handler: function() {
                        if (Ext.getCmp('login-form').getForm().isValid()) {
                            alert('Valid');
                        }
                    }
                } ]
            }
        }
    Cheers,
    Timothy

  2. #2
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996

    Default

    Code:
                buttons: [ {
                    text: 'Login',
                    handler: function(btn) {
                        var form = btn.ownerCt.ownerCt.getForm();
                        if (form.isValid()) {
                            alert('Valid');
                        }
                    }
                } ]

  3. #3

    Default

    Quote Originally Posted by mjlecomte View Post
    Code:
                buttons: [ {
                    text: 'Login',
                    handler: function(btn) {
                        var form = btn.ownerCt.ownerCt.getForm();
                        if (form.isValid()) {
                            alert('Valid');
                        }
                    }
                } ]
    Thanks! I wonder if it would be worth while submitting a request for a short hand property like form for buttons of a formpanel. Would be a great addition.

    Cheers,
    Timothy

Posting Permissions

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