-
16 Dec 2011 12:03 AM #1
Answered: Select/Date/Radio Field data not stored using getValues()
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 :
Here's the save button in the toolbar :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'} ] } ] });
My Controller :Code:{ xtype : 'button', text : 'save', ui : 'confirm', width : '25%', handler : function() { Ext.dispatch({ controller : 'Users', action : 'save', data : Ext.getCmp('formPane').getValues() }); } }
The store is set to autoLoadCode:save : function(params){ App.stores.ListStore.create(params.data); }
The model has a "localstorage" proxy & has string fields with matching ids to the form.
What am I doing wrong ???
-
Best Answer Posted by mitchellsimoensThe log prints out: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()); } } ] } ] });
Radios and checkboxes don't have a value if they are not checked.Code:{ date : null, name : "", paymeth : "green" }
-
16 Dec 2011 7:21 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
- Answers
- 3104
The log prints out: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()); } } ] } ] });
Radios and checkboxes don't have a value if they are not checked.Code:{ date : null, name : "", paymeth : "green" }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.


Reply With Quote