I am looking for some guidance on how to structure states, for forms
that can have a number of subtle overlapping changes. For example, a
form to add/edit a simple data type:
<mx:Panel title="Edit">
<mx:Form>
<mx:FormItem label="Title:">
<mx:TextInput id="titleField"/>
<mx:Label text="Title error goes here" id="titleError"/>
</mx:FormItem>
<mx:FormItem label="Type:">
<mx:ComboBox id="typeCombo"></mx:ComboBox>
</mx:FormItem>
<mx:FormItem label="New Type:">
<mx:TextInput id="newTypeField"/>
</mx:FormItem>
<mx:FormItem>
<mx:Button label="Update" id="saveButton"/>
</mx:FormItem>
</mx:Form>
</mx:Panel>
This form can either be used to create a new object (panel title
"Create New", button title "Save"), or edit an existing object (panel
title "Edit", button title "Update").
The "newTypeField" should only show if "create_new" was selected in
the "typeCombo".
When the "saveButton" is clicked, the button should be disabled and
its title should change to "Processing...".
If the save succeeds, the form should be replaced with a success message.
If the save fails, then an appropriate error message should appear
next to the invalid fields (ie the title error could be "Please
provide a title", "Title should be alphanumeric characters only",
"Title already taken, please choose another" etc). All fields may
have an error message, and I only want the error text to show (and
take up any space) if there is an error.
Can this be done with states? Most of these options are not exclusive
- they could happen regardless of any of the other "state" changes.
If not with states, how would you recommend it be done?