<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2007 FlexLib Contributors.  See:
    http://code.google.com/p/flexlib/wiki/ProjectContributors

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<!--

The Advanced Form component provides Reset, Undo and Redo functionality.

Undo and Redo are accessed by pressing "ctrl-Z" and "ctrl-Y" repsectively.

Simple validation support has been added.  The AdvancedForm searches for all
Validators in the same document as the form and sets Valid/Invalid listeners.
It then tracks all valid/invalid changes with a bindable "isValid" property.

The current component supports TextInput, TextArea, NumericStepper, 
RadioButton, CheckBox, and ComboBox.  They must be children of the Form 
or Form.FormItem components.

To see the application run go to http://renaun.com/flex2/AdvancedForm/
To see the application's source code go to http://renaun.com/flex2/AdvancedForm/srcview/

-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
	xmlns:flexlib="http://code.google.com/p/flexlib/"  
	layout="vertical"
	>

<mx:Script>
	<![CDATA[
        [Bindable]
        public var prefix: Array = [ {label:"Mr.", data:1}, 
            {label:"Mrs.", data:2}, {label:"Ms.", data:3} ];
           
	]]>
</mx:Script>
    <flexlib:AdvancedForm id="myForm" undoHistorySize="5">
    	<mx:FormItem>
	    	<mx:ComboBox id="titles" dataProvider="{ prefix }" selectedIndex="0" />    		
    	</mx:FormItem>
        <mx:FormItem label="First and Last Names" required="true">
            <mx:TextInput id="firstName" />
            <mx:TextInput id="lastName" />
        </mx:FormItem>
        <mx:FormItem label="Department">
            <mx:TextInput id="dept" text="Biology" />  
        </mx:FormItem>
		<mx:FormItem label="Other">
            <mx:NumericStepper id="age" value="25" minimum="1" maximum="100" stepSize="1" />
            <mx:CheckBox id="like" label="Do you like this code?" selected="true" />
            <mx:RadioButtonGroup id="survey"/>
        	<mx:RadioButton id="rd1" groupName="survey" label="It is Okay" selected="true" />
        	<mx:RadioButton id="rd2" groupName="survey" label="Normal" />	
        	<mx:RadioButton id="rd3" groupName="survey" label="It can use some work" />		
		</mx:FormItem>      
		  
    </flexlib:AdvancedForm>

	<!-- Validation -->
	<mx:Validator id="vldrFirstName" source="{ firstName }" property="text"
		required="true" />
	<mx:Validator id="vldrLastName" source="{ lastName }" property="text"
		required="true" />

	<mx:HBox>
		<mx:Button click="mx.controls.Alert.show( 'Submit Data', 'Alert' )" 
			label="Submit Data" enabled="{ myForm.isValid }" />
		<mx:Button click="myForm.resetForm()" label="Reset Form" />
	</mx:HBox>
	<!-- <mx:TextArea id="debug" width="600" height="300" />  -->
		
</mx:Application>
