6 Replies Latest reply on Dec 19, 2008 7:45 AM by hallik

    Dynamic Form Creation

    hallik
      So I have 3 tables: Users, Services, and MappedUsers. The MappedUsers Table first two columns are userID and serviceID, combining for a primary key. They are also foreign keys back to the users & services tables. Everytime a new user is created, there is an entry into the MappedUsers table for each service. So if there were 4 services available(1-4), There would be 4 inserts into MappedUsers like with special attention being paid to the 3rd & 4th column in that table: name(string) & allowed (boolean).

      What I am trying to do is dynamically create the FormItems for TextInput and Checkbox for these two items. So far I do have it dynamically generating the TextInputs & checkboxes complete with data already stored in the database. What I CANNOT figure out is how to update the DB by typing new values, checking/unchecking the boxes, whatever. How does it know which dynamically created row is associated with which serviceID, etc in the table?

      I saw the repeater doc here, and saw 3/4 of the page down about TextInputs and the repeaterIndices

      But I cannot figure out how it works. I have posted my mxml below, and all the way at the bottom of it is the repeater. The selectHandler function is what calls the PHP, executes the query, and returns the data object, then I push that object into the singleUser array and obviously it displays the data in the repeater. From there, updating the tables based on changes I make to what's in the repeater is where I am stuck.


        • 1. Re: Dynamic Form Creation
          Level 7

          "hallik" <webforumsuser@macromedia.com> wrote in message
          news:giencv$fa3$1@forums.macromedia.com...
          > So I have 3 tables: Users, Services, and MappedUsers. The MappedUsers
          > Table
          > first two columns are userID and serviceID, combining for a primary key.
          > They
          > are also foreign keys back to the users & services tables. Everytime a new
          > user
          > is created, there is an entry into the MappedUsers table for each service.
          > So
          > if there were 4 services available(1-4), There would be 4 inserts into
          > MappedUsers like with special attention being paid to the 3rd & 4th column
          > in
          > that table: name(string) & allowed (boolean).
          >
          > What I am trying to do is dynamically create the FormItems for TextInput
          > and
          > Checkbox for these two items. So far I do have it dynamically generating
          > the
          > TextInputs & checkboxes complete with data already stored in the database.
          > What
          > I CANNOT figure out is how to update the DB by typing new values,
          > checking/unchecking the boxes, whatever. How does it know which
          > dynamically
          > created row is associated with which serviceID, etc in the table?

          Store the key value(s) in the Value Object.


          • 2. Re: Dynamic Form Creation
            hallik Level 1
            Thanks for the reply. Can you explain a little further please? I'm still kind of new.
            • 3. Re: Dynamic Form Creation
              Level 7

              "hallik" <webforumsuser@macromedia.com> wrote in message
              news:giev7b$oeq$1@forums.macromedia.com...
              > Thanks for the reply. Can you explain a little further please? I'm still
              > kind of new.

              If you store the keys necessary to identify the object in the database in
              the object on the Flex side, then you can easily figure out what record
              you're referencing.

              Hope this clarifies;

              Amy


              • 4. Dynamic Form Creation
                hallik Level 1
                Yeah I am sorry that made sense, it's the manipulation of objects in flex I am still fumbling around in.The unique name and id are in the objects, But I wasn't' sure how to reference them properly. I am trying to create a function that looks at the data held in the selectedUser object and updates it with all data in the fields. If you have any tips, they are welcome. I will keep banging away though. :)

                I basically have an array of objects (selectedUser) I need to loop through, and don't know how to do that in the actionscript/flex code posted here. OR if it is easier, the singleUser var is an ArrayCollection An array of arrays. There is 4 entries in the array, and 6 properties in each array entry. Don't know the correct syntax for either one.

                Something like this? If singleUser is an array of objects, I can send the objects individually for inserts/updates to php with singleUser ....correct?


                • 5. Re: Dynamic Form Creation
                  Level 7

                  "hallik" <webforumsuser@macromedia.com> wrote in message
                  news:gif6ei$3dq$1@forums.macromedia.com...
                  > Yeah I am sorry that made sense, it's the manipulation of objects in flex
                  > I am
                  > still fumbling around in.The unique name and id are in the objects, But I
                  > wasn't' sure how to reference them properly. If you have any tips, they
                  > are
                  > welcome. I will keep banging away though. :)

                  If you're using Repeaters, you may find Question 9 useful
                  http://www.magnoliamultimedia.com/flex_examples/Amys_Flex_FAQ.pdf


                  • 6. Dynamic Form Creation
                    hallik Level 1
                    Oh man that's exactly what I needed. Nice FAQ! Thanks