PDA

View Full Version : How can I check vtypes with a button?



fff398
21 Jul 2010, 9:13 AM
I've learned how to do the basics of vtypes, creating a plugin, then linking it to a textfield.

My question is how to determine if a vtype is valid for a textfield(a panel of them) with a button click.



{
xtype: 'textfield',
name: 'phone',
vtype: 'phone',
plugins: new Ext.ux.plugin.FormatPhoneNumber()
}
...

..
buttons: [
{
text: submit
handler: function(){
//check vtypes of the panel for validity, emit warning if error
// then write to DB if passes
}
}
]

tomcruz
21 Jul 2010, 9:22 AM
you have to call isValid() on your form
http://www.sencha.com/deploy/dev/docs/?class=Ext.form.BasicForm

fff398
21 Jul 2010, 10:02 AM
another quick question, does calling the isValid() check all the children objects? like

formpanel
...
items: [pan1, pan2, pan3],
buttons: [{text: 'submit', handler: function(){ this.isValid()...}
..

and it'll check the vtypes in pan1, pan2, pan3?

tomcruz
22 Jul 2010, 2:34 AM
Yes, as far as I know the BasicForm has a collection of fields that is initialized recursively. so calling isValid on the top-level FormPanel should go through all the fields even if they're in a child panel.