How to create a form with multiple columns that are aligned and support all the features of the standard Form layout, such as marking form fields as required or optional, and handling error messages.
The Grid Layout does not support Form features such as marking form fields as required or optional, and handling error messages. I have created a new control based on the standard Form Layout, which enables 2 or more columns and for individual form items to span more than one column.
The new control introduces two new elements: MultiColumnForm and MultiColumnFormItem.
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:mc="nz.co.codec.flex.multicolumnform.*"
defaultButton="{save}"
label="Details"><mc:MultiColumnForm numColumns="2">
<mc:MultiColumnFormItem label="Phone">
<mx:TextInput id="phone" text="{_account.phone}"
width="100" />
</mc:MultiColumnFormItem>
<mc:MultiColumnFormItem label="Fax">
<mx:TextInput id="fax" text="{_account.fax}"
width="100" />
</mc:MultiColumnFormItem>
<mc:MultiColumnFormItem label="Physical Address" colspan="2"
width="100%">
<mx:TextInput id="physicalAddress1"
text="{_account.physicalAddress1}"
width="100%" />
<mx:TextInput id="physicalAddress2"
text="{_account.physicalAddress2}"
width="100%" />
</mc:MultiColumnFormItem>
<mc:MultiColumnFormItem label="City">
<mx:TextInput id="city" text="{_account.city}"
width="100" />
</mc:MultiColumnFormItem>
<mc:MultiColumnFormItem label="Postcode">
<mx:TextInput id="postcode" text="{_account.postcode}"
width="50" />
</mc:MultiColumnFormItem>
</mc:MultiColumnForm>MultiColumnForm {
horizontalGap: 10px;
}