Adobe recommends using the modern and extensible data capture Core Components for creating new Adaptive Forms or adding Adaptive Forms to AEM Sites pages. These components represent a significant advancement in Adaptive Forms creation, ensuring impressive user experiences. This article describes older approach to author Adaptive Forms using foundation components.
Authoring an adaptive form using an XML schema as its form model requires basic understanding of XML schemas. Also, it is recommended to read through the following content before this article.
Experience Manager Forms supports creation of an adaptive form by using an existing XML schema as the form model. This XML schema represents the structure in which data is produced or consumed by the back-end system in your organization.
The key features of using an XML schema are:
An XML schema consists of simple and complex element types. The elements have attributes that add rules to the element. When these elements and attributes are dragged onto an adaptive form, they are automatically mapped to the corresponding adaptive form component.
This mapping of XML elements with adaptive form components is as follows:
XML element or attribute | Adaptive form component |
---|---|
xs:string |
Text box |
xs:boolean |
Check box |
|
Numeric box |
xs:date |
Date picker |
xs:enumeration
|
Drop down |
Any complex-type element | Panel |
Here’s an example of an XML schema.
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="https://adobe.com/sample.xsd"
xmlns="https://adobe.com/sample.xsd"
xmlns:xs="https://www.w3.org/2001/XMLSchema"
>
<xs:element name="sample" type="SampleType"/>
<xs:complexType name="SampleType">
<xs:sequence>
<xs:element name="leaderName" type="xs:string" default="Enter Name"/>
<xs:element name="assignmentStartBirth" type="xs:date"/>
<xs:element name="gender" type="GenderEnum"/>
<xs:element name="noOfProjectsAssigned" type="IntType"/>
<xs:element name="assignmentDetails" type="AssignmentDetails"
minOccurs="0" maxOccurs="10"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="AssignmentDetails">
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="durationOfAssignment" type="xs:unsignedInt" use="required"/>
<xs:attribute name="numberOfMentees" type="xs:unsignedInt" use="required"/>
<xs:attribute name="descriptionOfAssignment" type="xs:string" use="required"/>
<xs:attribute name="financeRelatedProject" type="xs:boolean"/>
</xs:complexType>
<xs:simpleType name="IntType">
<xs:restriction base="xs:int">
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="GenderEnum">
<xs:restriction base="xs:string">
<xs:enumeration value="Female"/>
<xs:enumeration value="Male"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
Ensure that your XML schema has only one root element. An XML schema with more than one root element is not supported.
You can add the following attributes to XML Schema elements to add special properties to the fields of the associated adaptive form.
Schema property | Use in adaptive form | Supported in |
---|---|---|
use=required |
Marks a field mandatory |
Attribute |
default="default value" |
Adds a default value | Element and attribute |
minOccurs="3" |
Specifies minimum occurrences (For repeatable subforms (complex types)) |
Element (complex type) |
maxOccurs="10"
|
Specifies maximum occurrences (For repeatable subforms (complex types)) |
Element (complex type) |
When you drag a schema element to an adaptive form, a default caption is generated by:
For example, if you add the userFirstName
schema element, the caption generated in the adaptive form is User First Name
.
You can add the following restrictions to XML schema elements to limit the values acceptable to an adaptive form component:
Schema property |
Data Type |
Description |
Component |
|
String |
Specifies the maximum number of digits allowed in a component. The number of digits specified must be greater than zero. |
|
|
String |
Specifies the upper bound for numeric values and dates. By default, the maximum value is included. |
|
|
String |
Specifies the lower bound for numeric values and dates. By default, the minimum value is included. |
|
|
Boolean |
If true, the numeric value or date specified in the component of the form must be less than the numeric value or date specified for the maximum property. If false, the numeric value or date specified in the component of the form must be less than or equal to the numeric value or date specified for the maximum property. |
|
|
Boolean |
If true, the numeric value or date specified in the component of the form must be greater than the numeric value or date specified for the minimum property. If false, the numeric value or date specified in the component of the form must be greater than or equal to the numeric value or date specified for the minimum property. |
|
|
String |
Specifies the minimum number of characters allowed in a component. The minimum length must be equal to or greater than zero. |
|
|
String |
Specifies the maximum number of characters allowed in a component. The maximum length must be greater than zero. |
|
|
String |
Specifies the exact number of characters allowed in a component. The length must be equal to or greater than zero. |
|
|
String |
Specifies the maximum number of decimal places allowed in a component. The fractionDigits must be equal to or greater than zero. |
|
|
String |
Specifies the sequence of the characters. A component accepts the characters if the characters conform to specified pattern. The pattern property maps to the validation pattern of the corresponding adaptive form component. |
|
How do I know which element in the tree is associated with which XML element?
When you double-click an element in Content Finder, a pop-up window displays a field name and a property called bindRef
. This property maps the tree element to the element or attribute in the schema.
The bindRef
field shows the association between a tree element and an element or attribute in a schema.
Attributes have an @
symbol in their bindRef
value to distinguish them from elements. For example, /config/projectDetails/@duration
.
Why I am not able to drag individual elements of a subform (structure generated from any complex type) for repeatable subforms (minOccours or maxOccurs values are greater than 1)?
In a repeatable subform, you must use the Complete subform. If you want only selective fields, use the entire structure and delete the unwanted ones.
I have a long complex structure in Content Finder. How can I find a specific element?
You have two options:
What is a bindRef?
A bindRef
is the connection between an adaptive form component and a schema element or attribute. It dictates the XPath
where the value captured from this component or field is available in the output XML. A bindRef
is also used when prepopulating a field value from prefilled (prepopulated) XML.