The following example shows how you can change the FormItem container’s indicator skin which appears when the form item’s required property is set to true.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/10/06/changing-a-flex-formitem-containers-indicator-skin/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white">

    <mx:Style>
        FormItem {
            indicatorSkin: Embed(source="assets/asterisk_yellow.png");
            indicatorGap: 24; /* pixels */
        }

        FormItemLabel {
            textAlign: left;
        }
    </mx:Style>

    <mx:Form>
        <mx:FormHeading label="FORM HEADING" />
        <mx:FormItem label="Name:" required="true">
            <mx:TextInput />
        </mx:FormItem>
        <mx:FormItem label="Email:" required="true">
            <mx:TextInput />
        </mx:FormItem>
        <mx:FormItem label="Phone number:">
            <mx:TextInput />
        </mx:FormItem>
    </mx:Form>

</mx:Application>

View source is enabled in the following example.

 
Tagged with:
 
About The Author

Peter deHaan

Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.

5 Responses to Changing a Flex FormItem container’s indicator skin

  1. Anonymous says:

    Is there an easy way to move the indicator in front of the label?

  2. Is it possible to move required indicator to left ? I want to have it next to label (Form Item).

  3. Nathan5.x says:

    As Chetan Sachdev said, I too want the same..

    Hi Peter could you please suggest some idea on this. :)

  4. Ragu says:

    Use Assets.swf as image and assign infront of the required label. It works -:)

  5. Ragu says:

    <mx:HBox>
    <mx:Image
    source=”@Embed(source=’Assets.swf’,symbol=’mx.containers.FormItem.Required’)”
    height=”7″/>
    <mx:Label text=”Required field”/>
    </mx:HBox>

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree