-
checkbox and formbind
When using formbind in ext js 3, i can setup my textfields like this:
items:[{
name:'Username',
allowBlank:false
},{
name:'Password',
inputType:'password',
allowBlank:false
}],
but how do i setup a checkbox, which i want to be checked, using formbind, something like allownotchecked: false ?
-
Something like this?
Code:
Ext.ns('Ext.ux.form');
Ext.ux.form.Checkbox = Ext.extend(Ext.form.Checkbox, {
blankText : 'This field is required',
getErrors : function() {
var errors = Ext.ux.form.Checkbox.superclass.getErrors.call(this);
if (this.allowBlank === false && !this.getValue()) {
errors.push(this.blankText);
}
return errors;
}
});
Ext.reg('ux-checkbox', Ext.ux.form.Checkbox);
Ext.onReady(function() {
new Ext.form.FormPanel({
renderTo : document.body,
title : 'Test',
monitorValid : true,
items : [
{
xtype : 'textfield',
fieldLabel : 'Test',
allowBlank : false
},
{
xtype : 'ux-checkbox',
fieldLabel : 'Test',
allowBlank : false
}
],
buttons : [
{
xtype : 'button',
text : 'Submit',
formBind : true
}
]
});
});
-
hmm, i think so, in fact i only wanted to know the syntax in the item area for saying that the checkbox must be
checked, so i guess i can also use allowBlank for checkbox just like for textfields ? I will try it tomorrow, thanks for your help
-
allowBlank won't work on it's own, so if you look at my example I actually extended Combobox to handle it.
-