Form The Form page contains the following elements: Table 13. Form Element Description Form Initialization Actions Allows the List Form to be automatically pre-populated when the Form Type property is set to NewListItem, CreateDocument or UploadDocument. The List Form will call the defined custom actions that are specified in this property. The fields that cannot be automatically pre-populated are: • Auto-fill field (fixed value, consume value from an HTTP parameter, calculated format, consume value from a session, consume row from a row provided by another web part, auto fill with a lookup or cross-site lookup field) • BDC Column • SI Column • Complex category field • Cross site lookup field See the Custom Action Help chapter on how to write a custom action to initialize the list form. Turn on Advanced Mode if you want to edit Form Initialization Actions in XML format. <FormInitialization> <Action Name=”initial 1” Type="Custom" Class="MyCompany.DevStudio.SampleFormInitializationAction, MyCompany.DevStudio, Version=1.0.0.0, Culture=neutral, PublicKeyToken=451cac61f7ec4225" / > <Action Name=”initial 2” Type="Custom" Class="MyCompany.DevStudio.SampleFormInitializationAction2, MyCompany.DevStudio, Version=1.0.0.0, Culture=neutral, PublicKeyToken=451cac61f7ec4225" / > </FormInitialization> Form initialization is a way to auto fill the form. It should not be used in conjunction with another auto fill method. If you do this, the result is unpredictable (that is sometimes the value from form initialization will take precedence, but sometimes the value from the other auto fill method will take precedence). Form Component Behavior For more information, see Form Component Behavior Form Component Behavior This section is used to control the conditional behavior of the different components in the form, such as a field, a group of fields or a tab. There are four different conditional behaviors that can be specified: Show When, Hide When, Enabled When, and Disabled When. For fields, there are four additional conditional behaviors that can be specified: Valid When, Invalid When, Required When, and Default When. NOTE: You must configure Display Fields before configuring Form Component Behavior. You can define one or more form component definitions. Table 14. Definition Definition Description Advanced Mode Turn on if you want to edit Form Component Behavior in XML format. <FormComponentBehavior> <Component Type="Field/Group/Container" ID="ComponentID"> <ShowWhen> [Condition specified in CAML Filter format] </ShowWhen> <HideWhen> [Condition specified in CAML Filter format] </HideWhen> <EnabledWhen> [Condition specified in CAML Filter format] </EnabledWhen> <DisabledWhen> [Condition specified in CAML Filter format] </DisabledWhen> <InvalidWhen Message=”Custom Message when condition is true”> [Condition specified in CAML Filter format] </InvalidWhen> <ValidWhen Message=”Custom Message when condition is true”> [Condition specified in CAML Filter format] </ValidWhen> <RequiredWhen Message=”Custom Message when condition is true”> [Condition specified in CAML Filter format] </RequiredWhen> </Component> <Componet ...> <Component ...> </FormComponentBehavior> Type Defines the type of the component that is assigned the dynamic behavior. The choices are: Field, Group, or Container (that is, tab/panel). ID Defines the ID or name of the component whose behavior is defined to be dynamic. When the Type is set to Field, this ID refers to the Name of a field that is defined in the Display Fields property. When the Type is set to Group, this ID refers to the Group Name attribute of one or more fields defined in the Display Fields property. When the Type is set to Container, this ID refers to the ID of a container that is defined in the Form Layout property. To see details for a form component, you can configure the following properties: Table 15. Definition Properties Property Description Show When Defines the conditions of when the form component should be shown. Hide When Defines the conditions of when the form component should be hidden. This conditional behavior takes precedence over the Show When conditional behavior. Therefore, if Hide When and Show When are defined and both evaluate to true, the component is hidden. Enabled When Defines the conditions of when the form component should be enabled. Disabled When Defines the conditions of when the form component should be disabled. This conditional behavior takes precedence over the Enabled When conditional behavior. Therefore, if Enabled When and Disabled When are defined and both evaluate to true, the component is disabled. Required When Defines the conditions of when the form component should be required. This conditional behavior is for fields only. A custom message can be specified. It is displayed when the Required When condition is satisfied. The message is displayed by default in red after the input control on the form. However, you can specify any text or HTML code as the Message attribute. Valid When Defines the conditions of when the form component should be valid. This conditional behavior is for fields only. A custom message can be specified. It is displayed when the Valid When condition is satisfied. The message is displayed by default in red after the input control on the form. However you can specify any text or HTML code as the Message attribute. Invalid When Defines the conditions of when the form component should be invalid. This conditional behavior is for fields only. This conditional behavior takes precedence over the Valid When conditional behavior. Therefore, if Valid When and Invalid When are defined and both evaluate to true, the field is invalid. A custom message can be specified. It is displayed when the Invalid When condition is satisfied. The message is displayed by default in red after the input control on the form. However you can specify any text or HTML code as the Message attribute. Default When Defines the conditions of when the form component should be set as default. For fields of type text, numeric or date/time, regular expression matching can be used for validation. Use the “Matching” operator in the conditional behavior element. The following are some examples of how to use this property: 1 Show the Resolved Date and Resolved By fields when the Status field is changed to "Resolved". By specifying both fields’ GroupName attribute in the Display Fields property to “ResolvedFieldsGroup”, it is defined that both fields belong to the same group. <orFmComponentBehavior> <Component Type="Group" ID="ResolvedFieldsGroup"> <ShowWhen> <Eq><FieldRef Name="Status"/><Value Type="Choice">Resolved</Value></Eq> </ShowWhen> </Component>Enable the "Amount Paid" field when the Invoice Status fie </FormComponentBehavior> 2 ld is changed to "Paid". <FormComponentBehavior> <Component Type="Field" ID="Amount Paid"> <EnabledWhen> <Eq><FieldRef Name="Invoice Status"/><Value Type="Choice">Paid</Value></Eq> </EnabledWhen> </Component> </FormComponentBehavior> 3 Hide the Reason field when the Project Status field is not "Behind" <FormComponentBehavior> <Component Type="Field" ID="Reason"> <HideWhen> <Neq><FieldRef Name="Project Status"/><Value Type="Choice">Behind</Value></Neq> </HideWhen> </Component> </FormComponentBehavior> 4 Show error message if field, Assigned To, is blank when Status is “In Process” <FormComponentBehavior> <Component Type="Field" ID="Assigned To"> <InvalidWhen Message="Assigned To Must be filled if Status is In Process"> <And> <IsNull> <FieldRef Name="AssignedTo" /> </IsNull> <Eq> <FieldRef Name="Status" /> <Value Type="Choice">In Progress</Value> </Eq> </And> </InvalidWhen> </Component> </FormComponentBehavior> 5 Field % Complete must be between 0 and 100 <FormComponentBehavior> <Component Type="Field" ID="% Complete"> <ValidWhen Message="% Complete must be between 0 and 100"> <And> <Geq> <FieldRef Name="PercentComplete" /> <Value Type="Number">0</Value> </Geq> <Leq> <FieldRef Name="PercentComplete" /> <Value Type="Number">1</Value> </Leq> </And> </ValidWhen> </Component> </FormComponentBehavior> 6 Set the container to default when the Project Status field is "In-progress" <FormComponentBehavior> <Component Type="Container" ID="Initiation"> <DefaultWhen> <Neq><FieldRef Name="Project Status"/><Value Type="Choice">In-progress</Value></Neq> </DefaultWhen> </Component></FormComponentBehavior>