Results 1 to 2 of 2

Thread: .setValues for array form fields

  1. #1
    Sencha User
    Join Date
    Jan 2011
    Location
    Denver, Co
    Posts
    9
    Vote Rating
    1
      1  

    Default .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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

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
  •