1. #1
    Sencha User
    Join Date
    Mar 2013
    Posts
    3
    Vote Rating
    0
    peturkirke is on a distinguished road

      0  

    Default 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 ?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    438
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    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.

  3. #3
    Sencha User
    Join Date
    Mar 2013
    Posts
    3
    Vote Rating
    0
    peturkirke is on a distinguished road

      0  

    Default


    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

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    438
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    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.

  5. #5
    Sencha User
    Join Date
    Mar 2013
    Posts
    3
    Vote Rating
    0
    peturkirke is on a distinguished road

      0  

    Default


    ok ... thanks again