Results 1 to 2 of 2

Thread: Select/Date/Radio Field data not stored using getValues()

  1. #1
    Sencha User
    Join Date
    Aug 2011
    Location
    Mumbai, India
    Posts
    120
    Answers
    11
    Vote Rating
    4
      0  

    Default Answered: Select/Date/Radio Field data not stored using getValues()

    Hi,

    I have a form panel containing various text fields, one selectfield, one datepickerfield, and one radiofield. I have a save button that when pressed dispatches to a controller which saves the data to the store and then populates a list that uses that store. The textfield data saves to the store wid no problems. But the select, datepicker and radio fields do not. Please help.

    Heres the code for the form :

    Code:
    var formPane = new Ext.form.FormPanel ({
        id : 'formPane',
        items: [
            {
                xtype : 'fieldset',
                title : 'Form Details',
                defaults : {
                      labelAlign : 'left',
                      labelWidth : '40%',
                      required : false,
                      useClearIcon : true,
                      autoCapitalize: false
                },
                items : [
                    {
                        xtype: 'textfield',
                        id : 'name',
                        name : 'name',
                        label: 'Name'
                    },
                    {
                        xtype: 'selectfield',
                        name : 'categ',
                        id : 'categ',
                        label: 'Category',
                        valueField : 'categv',
                        displayField : 'title',
                        store : BReimb.stores.categsStore
                    },
                    {
                        xtype: "datepickerfield",
                        name: "date",
                        id : 'date',
                        label: "Date",
                        picker: {yearFrom: 2010}  
                    },
                ]
            },
            {
                xtype : 'fieldset',
                title : 'Radio Details',
                layout : 'hbox',
                defaults : {xtype : 'radiofield'},
                items : [
                    {name : 'paymeth', label: 'Cash', value : 'red', width: '50%'},
                    {name : 'paymeth', width: '50%', label: 'Card' , checked : true, value : 'green'}
                ]
            }
       ]
    });
    Here's the save button in the toolbar :
    Code:
    {
                xtype : 'button',
                text : 'save',
                ui : 'confirm',
                width : '25%',
                handler : function() {
                    Ext.dispatch({
                        controller : 'Users',
                        action : 'save',
                        data : Ext.getCmp('formPane').getValues()
                    });
                 }
    }
    My Controller :
    Code:
    save : function(params){
            App.stores.ListStore.create(params.data);
    }
    The store is set to autoLoad
    The model has a "localstorage" proxy & has string fields with matching ids to the form.

    What am I doing wrong ???

  2. Code:
    new Ext.form.FormPanel({
        fullscreen : true,
        items      : [
            {
                xtype : 'fieldset',
                title : 'Form Details',
                defaults : {
                      labelAlign : 'left',
                      labelWidth : '40%',
                      required : false,
                      useClearIcon : true,
                      autoCapitalize: false
                },
                items : [
                    {
                        xtype: 'textfield',
                        id : 'name',
                        name : 'name',
                        label: 'Name'
                    },
                    {
                        xtype: "datepickerfield",
                        name: "date",
                        id : 'date',
                        label: "Date",
                        picker: {yearFrom: 2010}
                    }
                ]
            },
            {
                xtype : 'fieldset',
                title : 'Radio Details',
                layout : 'hbox',
                defaults : {xtype : 'radiofield'},
                items : [
                    {name : 'paymeth', label: 'Cash', value : 'red', width: '50%'},
                    {name : 'paymeth', width: '50%', label: 'Card' , checked : true, value : 'green'}
                ]
            }
        ],
        dockedItems : [
            {
                xtype : 'toolbar',
                dock  : 'bottom',
                items : [
                    {
                        text    : 'Save',
                        ui      : 'confirm',
                        handler : function(btn) {
                            var form = btn.up('form');
    
                            console.log(form.getValues());
                        }
                    }
                ]
            }
        ]
    });
    The log prints out:

    Code:
    {
        date    : null,
        name    : "",
        paymeth : "green"
    }
    Radios and checkboxes don't have a value if they are not checked.

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,335
    Answers
    3885
    Vote Rating
    1296
      0  

    Default

    Code:
    new Ext.form.FormPanel({
        fullscreen : true,
        items      : [
            {
                xtype : 'fieldset',
                title : 'Form Details',
                defaults : {
                      labelAlign : 'left',
                      labelWidth : '40%',
                      required : false,
                      useClearIcon : true,
                      autoCapitalize: false
                },
                items : [
                    {
                        xtype: 'textfield',
                        id : 'name',
                        name : 'name',
                        label: 'Name'
                    },
                    {
                        xtype: "datepickerfield",
                        name: "date",
                        id : 'date',
                        label: "Date",
                        picker: {yearFrom: 2010}
                    }
                ]
            },
            {
                xtype : 'fieldset',
                title : 'Radio Details',
                layout : 'hbox',
                defaults : {xtype : 'radiofield'},
                items : [
                    {name : 'paymeth', label: 'Cash', value : 'red', width: '50%'},
                    {name : 'paymeth', width: '50%', label: 'Card' , checked : true, value : 'green'}
                ]
            }
        ],
        dockedItems : [
            {
                xtype : 'toolbar',
                dock  : 'bottom',
                items : [
                    {
                        text    : 'Save',
                        ui      : 'confirm',
                        handler : function(btn) {
                            var form = btn.up('form');
    
                            console.log(form.getValues());
                        }
                    }
                ]
            }
        ]
    });
    The log prints out:

    Code:
    {
        date    : null,
        name    : "",
        paymeth : "green"
    }
    Radios and checkboxes don't have a value if they are not checked.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •