PDA

View Full Version : Ext.FormPanel Button Question



netski
16 Jul 2009, 5:58 PM
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?



{
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

mjlecomte
16 Jul 2009, 6:06 PM
buttons: [ {
text: 'Login',
handler: function(btn) {
var form = btn.ownerCt.ownerCt.getForm();
if (form.isValid()) {
alert('Valid');
}
}
} ]

netski
17 Jul 2009, 3:58 AM
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