1. #1
    Sencha User
    Join Date
    Jan 2011
    Location
    Denver, Co
    Posts
    9
    Vote Rating
    1
    willjohnathan is on a distinguished road

      1  

    Default .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
    Code:
    formName.getForm().setValues({
     field_a     : value_a,
     field_b     : value_b,
     field_c[0]  : value_c[0],
     field_c[1]  : value_c[1]
    });
    Any Suggestions?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,203
    Vote Rating
    856
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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
    ________________
    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.

Thread Participants: 1

Tags for this Thread