<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2006 Renaun Erickson (http://renaun.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

@ignore
-->
<!--

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:form="com.renaun.containers.*" layout="vertical" viewSourceURL="srcview/index.html"
    initialize="Logger.enabled = true">

<mx:Script>
    <![CDATA[
        [Bindable]
        public var prefix: Array = [ {label:"Mr.", data:1}, 
            {label:"Mrs.", data:2}, {label:"Ms.", data:3} ];
           
    ]]>
</mx:Script>
    <form: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>      
          
    </form: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>