Form Layout Container in Flex4

The Form Layout container is a MX container. There is no Spark equivalent. Flex uses the Form Layout container for making a Form.


Share on Google+Share on Google+

Form Layout Container in Flex4


The Form Layout container is a MX container. There is no Spark equivalent. Flex uses the Form Layout container for making a Form.

Form Layout Container in Flex4:

The Form Layout container is a MX container. There is no Spark equivalent.
Flex uses the Form Layout container for making a Form. The Form container controls the layout of form, required field option, validation and binding the data to the flex data model for checking a valid data. You can use the style sheet for better appearance of form. You can use the FormHeading component for show the form heading like Registration Form. The FormHeading component nested in the Form container. The FormItem component is used for form fields which is in your form like Name, Age and contact no. etc. You can use the verticalGap property for gap between two form items, indicator property for gap between field name and component. You can use the validator for validating a component value. The tag of Form container is <mx:Form>.


<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx=""



minWidth="955" minHeight="600" height="634">








<mx:StringValidator source="{txt1}" property="text" minLength="4" maxLength="12"/>

<mx:PhoneNumberValidator source="{txt11}" property="text"/>

<mx:EmailValidator source="{txt4}" property="text"/>

<mx:ZipCodeValidator source="{txt10}" property="text"/>


<s:Panel title="Form Layout Container Example" width="599" height="572">




<mx:Form backgroundColor="0x003366" width="598">

<mx:FormHeading label="Registration Form" fontSize="18" fontFamily="verdhana" color="white"/>

<mx:FormItem label="User Name:" required="true" labelStyleName="field">

<mx:TextInput id="txt1" text="User Name" fontStyle="italic"/>


<mx:FormItem label="First Name:" labelStyleName="field">

<mx:TextInput id="txt2" text="First Name" fontStyle="italic"/>


<mx:FormItem label="Last Name:" labelStyleName="field">

<mx:TextInput id="txt3" text="Last Name" fontStyle="italic"/>


<mx:FormItem label="Email-ID:" required="true" labelStyleName="field">

<mx:TextInput id="txt4" text="Email ID" fontStyle="italic"/>


<mx:FormItem label="Password:" required="true" labelStyleName="field">

<mx:TextInput id="txt5" text="Password" displayAsPassword="true"/>


<mx:FormItem label="Confirm Password:" required="true" labelStyleName="field">

<mx:TextInput id="txt6" text="Confirm Password" displayAsPassword="true"/>


<mx:FormItem label="Gender:" labelStyleName="field">


<s:RadioButton groupName="gen" label="Male" selected="true" color="white"/>

<s:RadioButton groupName="gen" label="Female" color="white"/>



<mx:FormItem label="Marital Status:" labelStyleName="field">


<s:RadioButton id="gen1" label="Single" selected="true" color="white"/>

<s:RadioButton id="gen2" label="Married" color="white"/>



<mx:FormItem label="D.O.B.:" required="true" labelStyleName="field">

<mx:DateField text="Select Date" fontStyle="italic"/>


<mx:FormItem label="Address:" labelStyleName="field">

<mx:TextInput id="txt7" text="Address line 1" fontStyle="italic"/>



<mx:TextInput id="txt8" text="Address line 2" fontStyle="italic"/>


<mx:FormItem label="City:" labelStyleName="field">

<mx:TextInput id="txt9" text="City" fontStyle="italic"/>


<mx:FormItem label="State:" labelStyleName="field">

<s:DropDownList id="drp" width="161" prompt="Select State">


<fx:String>Uttar Predesh</fx:String>








<mx:FormItem label="ZIP Code:" labelStyleName="field">

<mx:TextInput id="txt10" text="ZIP Code" fontStyle="italic"/>


<mx:FormItem label="Mobile No.:" required="true" labelStyleName="field">

<mx:TextInput id="txt11" text="+91 Mobile No" fontStyle="italic"/>



<s:CheckBox label="I accept the term and conditions" color="white"/>




<s:Button id="btn" label="Submit"/>

<s:Button id="btn1" label="Reset"/>







In this example you can see how we can use a Form Layout Container control in Flex4.


Running Application:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

Download this code



Posted on: May 18, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles