Create and use Adaptive Forms Fragments in an Adaptive Form based on Core Components adaptive-form-fragments

Version
Article link
AEM as a Cloud Service (Core Components)
This article
AEM as a Cloud Service (Foundation Components)
Click here
AEM 6.5
Click here

While every form is designed for a specific purpose, there are some common segments in most forms, such as to provide personal details like name and address, family details, income details. Form developers are required to create these common segments every time a new form is created.

Adaptive Forms provides a convenient mechanism to create form segment like a panel or a group of fields only once and reuse them across Adaptive Forms. These reusable and standalone segments are called Adaptive Form fragments.

Form fragments seamlessly integrate into multiple forms, streamlining the creation of consistent and professional-looking forms. Form Fragments ensure reusability, standardization, and brand consistency through ‘change once and reflect everywhere’ functionality. Experience greater maintainability and efficiency as updates made in one place are automatically propagated across all forms that utilize these fragments.

You can add a fragment multiple times to a document and use data binding properties of its components to tie it to different data sources or schema. For example, you can use the same address fragment for permanent, communication, and billing address and connect it to different fields of a data sources or schema.

NOTE
You can easily customize your fragment experience for users with the Configure dialog and Design dialog of Form Fragment component.

Create an Adaptive Form Fragment create-a-fragment

You can create an Adaptive Form Fragment from scratch or save a panel in an existing Adaptive Form as fragment. To create a form fragment:

  1. Log in to your AEM Forms instance at https://[hostname]:[port]/aem/forms.html.

  2. Click Create > Adaptive Form Fragment.

    Create Adaptive Form Fragment

  3. Specify title, name, description, and tags for the fragment. Ensure that you specify a unique name for the fragment. If another fragment exists with the same name, the fragment fails to create.

  4. Select a form template. You can create a form fragment for Core Components based Adaptive Forms or Foundation Components based Adaptive Forms. To create form fragment for Core Components based forms, select a Core Components based template.

    When you create form fragment for Core Components based forms, use the Select Form Theme option to select a Core Components based theme.

  5. Click to open the Form Model tab, and from the Select From drop-down menu, select one of the following models for the fragment:

    Displays model type in the Form Model tab

    • None: Specifies to create the fragment from scratch without using any form model.

      note note
      NOTE
      In Adaptive Forms, you can use single form fragment (based on Core Components) multiple times. It supports both none-based and schema-based form fragments.
    • Schema: Specifies to create the fragment using an XML or JSON schema uploaded to AEM Forms. You can upload or select from the available XML or JSON schemas as the form model for the fragment. When you select an XML schema, you can also create an Adaptive Form fragment by selecting a complexType present in the selected schema from the XML Schema Complex Type drop-down box. When you select a JSON schema, you can also create an Adaptive Form fragment by selecting a schema definition present in the selected schema from the JSON Schema Definitions drop-down box.

    • Form Data Model: Specifies to create the fragment using a form data model (FDM). You can create an Adaptive Form fragment based on only one data model object in a form data model (FDM). Expand Form Data Model (FDM) Definitions drop-down. It lists all data model objects in the specified form data model(FDM). Select a data model object from the list.

    Form Data Model (FDM)

  6. Click Create and then click Open to open the fragment, with a default template, in edit mode. In edit mode, you can add any Adaptive Form component to the fragment.

Once the Adaptive Form fragment based on a schema or form data model (FDM) is created, form data model (FDM) or schema elements appear in the Data Sources tab of the Content browser in Adaptive Form editor. You can drag-and-drop form-model elements onto the fragment. The added form-model elements are converted to form components while retaining the original properties from the associated schema.

Add a fragment to an Adaptive Form insert-a-fragment-in-an-adaptive-form

To add an Adaptive Form fragment to an Adaptive Form:

  1. Open the Adaptive Form in edit mode.

  2. Add the Adaptive Form Fragment component to the form.

  3. Open the Configuration dialog of Adaptive Form Fragment component.

  4. Select the Fragment reference in the Basic tab. All the Adaptive Forms fragments available for your form, depending on the model of the form, appear.

  5. Select an Adaptive Form fragment onto the Adaptive Form Fragment component on your Adaptive Form.

    select the Adaptive Form Fragments option

The Adaptive Form fragment is added by reference to the Adaptive Form and remains in synchronized with the standalone Adaptive Form fragment. This implies that any modifications made to the Adaptive Form fragment are mirrored across all instances where the fragment is incorporated within Adaptive Forms.

Using fragments within fragments using-fragments-within-fragments

You can create nested Adaptive Form fragments, which means you can add a fragment in another fragment, and can have nested fragment structure.

Using a form fragment multiple times in an Adaptive Form using-form-fragment-mutiple-times-in-af

You can use a none-based and schema-based form fragment multiple times in an Adaptive Form to save data uniquely for each form fragments fields. For example, you can use an address form fragment to collect address details for permanent, communication, and present living addresses in a loan application form.

using multiple fragment in adaptive form

Manage fragments manage-fragments

You can perform several operations on Adaptive Form fragments using the AEM Forms UI.

  1. Go to https://[hostname]/aem/forms.html.

  2. Click Select in the AEM Forms UI toolbar and select an Adaptive Form Fragment. The toolbar displays the following operations you can perform on the selected Adaptive Form fragment.

Operation
Description
Edit
Opens the selected Adaptive Form fragment in edit mode.
Preview
Provides options to preview the fragment as an HTML or a custom preview by merging data from an XML file with the fragment. For more information, see Previewing a form.
Download
Downloads the selected fragment.
Start Review/Manage Review
Allows initiating and managing a review of the selected fragment. For more information, see Creating and managing reviews.
Add Dictionary
Generates a dictionary for localizing the selected fragment. For more information, see Localizing Adaptive Forms.
Publish / Unpublish
Publishes / unpublishes the selected fragment.
Delete
Deletes the selected fragment.

Key points to remember when working with fragments key-points-to-remember-when-working-with-fragments

  • Ensure that the fragment name is unique. The fragment fails to create if there is an existing fragment with the same name.
  • Any expression, script, or style in a stand-alone Adaptive Form fragment is retained when it is inserted by reference or embedded in an Adaptive Form.
  • You cannot edit an Adaptive Form fragment, which is inserted by reference, from within an Adaptive Form. To edit, modify the stand-alone Adaptive Form fragment.
  • When you publish an Adaptive Form, you need to publish the standalone Adaptive Form fragments inserted by reference in the Adaptive Form.
  • When you republish an updated Adaptive Form fragment, the changes reflect in the published instances of the Adaptive Form in which the fragment is used.
  • Adaptive Form containing the Verify component does not support anonymous users. Also, it is not reommended to use the Verify component in an Adaptive Form fragment.

Reference Fragments reference-fragments

Reference Adaptive Form fragments that you can use to create your form are available.

See Also see-also

recommendation-more-help
fbcff2a9-b6fe-4574-b04a-21e75df764ab