Form Data Model Value : Form « Components « Flex






Form Data Model Value

Form Data Model Value
           

<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->


<!-- containers\layouts\FormDataModelVal.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    xmlns:s="library://ns.adobe.com/flex/spark">
    <!-- Define the submit function that validates and processes the data -->
    <fx:Script>
         
        private function processValues():void { 
            var inputZip:String = myFormModel.zipCodeModel; 
            var inputPhone:String = myFormModel.phoneNumberModel; 
            // Process data. 
        } 
      
    </fx:Script>
    <fx:Declarations>
        <!-- Define data model. -->
        <fx:Model id="myFormModel">
            <info>
                <zipCodeModel>{zipCode.text}</zipCodeModel>
                <phoneNumberModel>{phoneNumber.text}</phoneNumberModel>
            </info>
        </fx:Model>
        <!-- Define validators. -->
        <mx:ZipCodeValidator source="{myFormModel}" property="zipCodeModel"
            trigger="{zipCode}" listener="{zipCode}" />
        <mx:PhoneNumberValidator source="{myFormModel}"
            property="phoneNumberModel" trigger="{b1}" listener="{phoneNumber}"
            triggerEvent="click" />
    </fx:Declarations>
    <!-- Define the form. -->
    <mx:Form borderStyle="solid">
        <mx:FormItem label="ZIP Code">
            <mx:TextInput id="zipCode" />
        </mx:FormItem>
        <mx:FormItem label="Phone Number">
            <mx:TextInput id="phoneNumber" />
        </mx:FormItem>
        <mx:FormItem>
            <mx:Button id="b1" label="Submit" click="processValues();" />
        </mx:FormItem>
    </mx:Form>
</s:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Making use of form-related containersMaking use of form-related containers
2.Form Radio button groupForm Radio button group
3.Login form and get password back formLogin form and get password back form
4.Add submitForm() and debugMessage() functions as click event handlersAdd submitForm() and debugMessage() functions as click event handlers
5.Register the submitForm() and debugMessage() handler functions with b1's click eventRegister the submitForm() and debugMessage() handler functions with b1's click event
6.Clear form fieldsClear form fields
7.Form item labelForm item label
8.Empty form tag
9.FormHeading controlFormHeading control
10.A form for first name, last name, address, city, zip code and countryA form for first name, last name, address, city, zip code and country
11.Form Text required fieldForm Text required field
12.submit function can access the form control data directlysubmit function can access the form control data directly
13.Populating a Form control from a data modelPopulating a Form control from a data model
14.Switch form with TransitionSwitch form with Transition
15.Form control barForm control bar
16.Form field with LabelForm field with Label
17.Add the submitForm() and debugMessage() functions as handlers of the click event:Add the submitForm() and debugMessage() functions as handlers of the click event:
18.Register the submitForm() and debugMessage() handler functionsRegister the submitForm() and debugMessage() handler functions
19.Add form header to a formAdd form header to a form
20.Bind form input control to ModelBind form input control to Model
21.Form label with iconForm label with icon
22.One form two FormHeadingsOne form two FormHeadings
23.Model data and form controls
24.Password form fieldPassword form field
25.Contact Editor FormContact Editor Form
26.Travel formTravel form
27.Form with ControlBarForm with ControlBar
28.Form Multiple HeadingsForm Multiple Headings
29.Adding border to FormAdding border to Form
30.defines the FormHeading controldefines the FormHeading control
31.Using Form controls to hold your form dataUsing Form controls to hold your form data
32.The submit function can access the form control data directly,The submit function can access the form control data directly,
33.A form that reads static data from a data model to obtain the value for a form fieldA form that reads static data from a data model to obtain the value for a form field
34.Adding a load event and a fault event to the form.Adding a load event and a fault event to the form.
35.Select a value for the formatString property from the drop-down listSelect a value for the formatString property from the drop-down list
36.Show individual times for the initialization and creation of each form element.Show individual times for the initialization and creation of each form element.
37.Register a single listener function, submitForm(), with two different buttonsRegister a single listener function, submitForm(), with two different buttons
38.Form ButtonForm Button
39.Form default buttonForm default button
40.The form and the buttons overlap as the application grows smaller, for example.The form and the buttons overlap as the application grows smaller, for example.
41.Form with ButtonForm with Button
42.Login ExampleLogin Example
43.Checking the box could make the user e-mail field requiredChecking the box could make the user e-mail field required