-
2 Nov 2011 11:07 AM #1
.setValues for array form fields
.setValues for array form fields
I have a large form that allows users to save to and open from a database. When loading data from the database I am using the setValues method (see code below) that way I can reference each input by its name. This is working fine until I get to inputs on the form that I have set as an array. Is there a simple way to load these values using this same method. I am thinking of just giving these inputs an id and referencing them by id during the load process, but I would prefer to not have to do that for every time I have a form that uses arrays.
This does not work
Any Suggestions?Code:formName.getForm().setValues({ field_a : value_a, field_b : value_b, field_c[0] : value_c[0], field_c[1] : value_c[1] });
-
18 Nov 2011 11:10 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
id is not a good idea for production. If setValues don't fit your needs, iterate through the items and set the value on each field but this way you can add some logic, that's what setValues does.
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