-
18 Mar 2013 9:24 AM #1
checkbox and formbind
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 ?
-
20 Mar 2013 1:05 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
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 } ] }); });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
20 Mar 2013 4:09 PM #3
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
-
21 Mar 2013 5:07 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
allowBlank won't work on it's own, so if you look at my example I actually extended Combobox to handle it.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
21 Mar 2013 6:36 AM #5


Reply With Quote