1 Reply Latest reply on Feb 7, 2008 3:22 PM by ntsiii

    Child layout in VBox vs in Form

    Loldemort
      I'm just starting Flex development, busily reading and trying out examples. I've got an existing form in an application that I'd like to move over from HTML to flex, as a test. The existing form has a tab set in it. I got as far as laying out all the controls in a form inside a flex application and looking at it in a browser. All very pretty, if not yet functional, and all child labels and controls nicely aligned. Then I put an accordion inside the form, added VBoxes as the children of the accordion, one for each tab, and moved the FormItems containing the controls into the appropriate VBoxes.

      Well the accordion appeared with the tabs as expected, but inside the display areas, the child controls are all higgledy-piggledy. Commenting out the accordion tags but leaving the formitems inside the vboxes left the controls still misaligned, further commenting out the VBoxes so that the formitems are once more directly children of the form, and they line up nicely again. Which seems to prove that it's the VBoxes, not the accordion, that's the problem: they just don't lay out their children nicely.

      What's the solution? I've tried putting forms inside the accordion instead of VBoxes, and the controls now line up properly, but I'm not sure if this is good practice. Forms inside an accordion inside another form - will this mess up the data binding? Or should I remove the outer form, make the accordion a direct child of the application, and use multiple forms as direct children of the accordion, and somehow make the data binding work?

      This must be a common newbie problem, but as far as I can see, all the examples available fail to address it. It's as though they've avoided it on purpose...


      Cheers.
        • 1. Re: Child layout in VBox vs in Form
          ntsiii Level 3
          A container handles the layout of its own children. Putting form items in a VBox makes no sense, as only Form treats them specially.

          I have actually never used Form, but if the validation functionality is important to you, then use individual forms within the Accordion, and lose the outer form. You will need to break up your data into individual items to use binding.

          Note that you can validate fields without a Form. You can bind without a Form.

          Tracy