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.
Version | Article link |
---|---|
AEM 6.5 | This article |
AEM as a Cloud Service | Click here |
With AEM Forms, you can seamlessly incorporate adaptive forms into your web pages. This allows your visitors to conveniently fill and submit forms without ever leaving the page they are on. By doing so, they can effortlessly stay engaged with other elements of the website while actively interacting with the form.
You can use AEM Page Editor to quickly create and add multiple forms to your AEM Sites pages. Using AEM Page Editor allows content authors to create seamless data capture experiences within a Sites page using the power of adaptive forms components including dynamic behavior, validations, data integration, generate document of record and business process automation. It also lets you use various features of AEM Sites pages like, versioning, targeting, translation, and multi-site manager.
AEM Forms provide Adaptive Form Container and Adaptive Forms – Embed components. You can use Adaptive Form Container to create a form in an Experience Fragment or AEM Sites page, while Adaptive Forms – Embed component lets you add an existing Adaptive Form or create a form using Adaptive Forms Editor.
Using Adaptive Form Container in AEM Page Editor lets you create seamless data capture experiences within a Sites page using the power of Adaptive Forms components including dynamic behavior, validations, data integration, generate document of record and business process automation. It also lets you use various features of AEM Sites pages like, versioning, targeting, translation, and multi-site manager, enhancing the overall form creation and management experience. Let’s explore some of these features:
You can take full advantage of this feature by utilizing the following options:
Add a custom Adaptive Form to an AEM Sites page: Build a brand-new form from scratch, tailoring it specifically to your requirements and design preferences.
Add a custom Adaptive Form to an Experience Fragments: Extend the reach of your forms by adding them to AEM Experience Fragments, allowing for seamless reuse across multiple pages or sites.
Convert an Adaptive Form to Experience Fragment: Convert an Adaptive Form added to an AEM Sites page to an Experience Fragment for reusing the form across multiple AEM Sites pages.
Create and add forms based on approved templates to an AEM Sites page: Leverage pre-approved templates to quickly create forms that align with your organization’s branding guidelines and design standards. The option is available only for Adaptive Forms created with Adaptive Forms Editor or Adaptive Forms - Embed component.
Add existing forms to an AEM Sites page: Easily integrate forms that you have already created into your websites, enabling visitors to interact with them directly. The option is available only for Adaptive Forms created with Adaptive Forms Editor or Adaptive Forms - Embed component.
Add multiple forms to an AEM Sites page or Experience Fragment: Add multiple forms to a page to provide multiple choices to users based on their preferences and requirements. These can a combination of brand-new form from scratch and existing forms.
When you use the Adaptive Form Container to create or add a form, the forms undergo translation and localization through the AEM Sites translation flow. For each language, a separate copy (language copy) of the sites page and corresponding forms is generated and when a content author modifies a rule in a form on the parent page, the same changes must be made in all language copies of the form. Adaptive Form Container also lets you use various features of AEM Sites pages like, versioning, targeting, translation, and multi-site manager.
When you create or add a form using the Adaptive Form-embed component, the forms undergo translation and localization using the AEM Forms translation flow. In this case, a single form is maintained and referenced in all the language copies of the Sites pages. Adaptive Form-embed component does not provide access to various features of AEM Sites pages like, versioning, targeting, translation, and multi-site manager.
Ensure that the Adaptive Forms Core Components are enabled for your environment.
To enable complete functionality of the Adaptive Forms Container component, add the Customheaderlibs and Customfooterlibs client libraries to your AEM Sites page using the deployment pipeline. To add the libraries:
Login to your AEM Author instance and open CRX DE. The default URL for an Author instance running locally is http://localhost:4502/crx/de
.
Open the /apps/[your-sites-project]/components/page/customheaderlibs.html
file and add the following code to the file:
//Customheaderlibs.html
<sly data-sly-use.clientlib="core/wcm/components/commons/v1/templates/clientlib.html">
<sly data-sly-call="${clientlib.css @ categories='core.forms.components.runtime.all'}"/>
</sly>
Open the /apps/[your-sites-project]/components/page/customfooterlibs.html
file and add the following code to the file:
//customfooterlibs.html
<sly data-sly-use.clientlib="core/wcm/components/commons/v1/templates/clientlib.html">
<sly data-sly-test="${!wcmmode.edit}" data-sly-call="${clientlib.js @ categories='core.forms.components.runtime.all', async=true}"/>
</sly>
Open the /apps/[your-sites-project]/components/xfpage/customheaderlibs.html
file and add the following code to the file:
//Customheaderlibs.html
<sly data-sly-use.clientlib="core/wcm/components/commons/v1/templates/clientlib.html">
<sly data-sly-call="${clientlib.css @ categories='core.forms.components.runtime.all'}"/>
</sly>
Open the /apps/[your-sites-project]/components/customfooterlibs.html
file and add the following code to the file:
//customfooterlibs.html
<sly data-sly-use.clientlib="core/wcm/components/commons/v1/templates/clientlib.html">
<sly data-sly-test="${!wcmmode.edit}" data-sly-call="${clientlib.js @ categories='core.forms.components.runtime.all', async=true}"/>
</sly>
Repeat the above steps all the Author and Publish instances in your environment.
To enable Adaptive Forms Container component in template’s policy, perform the following steps:
You can create a brand-new form from scratch, tailoring it specifically to your requirements and design preferences, directly in an AEM Sites page or in Experience Fragment. For single-use forms, direct authoring to an AEM Sites page is recommended, while Experience Fragments are ideal for forms that need to be reused across multiple pages on your website.
You can use the Adaptive Form Container component in AEM Page Editor to create a custom form. The component lets you create a form by dragging and dropping the form components. The form components are based on Core Components. You can easily customize these as per the requirement of your organization.
To create an Adaptive Form in a Sites page:
Next, you set the Submit Action and advanced properties.
You can extend the reach of your forms by adding them to AEM Experience Fragments, allowing for seamless reuse across multiple pages or sites. For example, you can include a newsletter signup form within an Experience Fragment. This lets you conveniently reuse the fragment across multiple pages of your website, eliminating the need to recreate the form repeatedly. Any updates or modifications made to the newsletter signup form within the Experience Fragment are automatically propagated to all the pages where it is utilized. This streamlines the process and ensures a seamless user experience while simplifying the management of your website’s forms.
To create an Adaptive Form in an Experience Fragment:
Next, you set the Submit Action and advanced properties.
You can convert an existing Adaptive Form in a Sites Page Editor to an Experience Fragment to reuse the form across multiple pages or sites.
To convert an Adaptive Form in AEM Sites page to an Experience Fragment:
Open the AEM Sites page containing the Adaptive Form (in Adaptive Forms Container component) in edit mode.
Open the Content Tree, and select the Adaptive Forms Container that hosts your Adaptive Form. An AEM Sites page can host multiple Adaptive Forms. So, carefully select the correct Adaptive Forms Container.
On the menu bar, select the Convert to Experience Fragment variation icon.
A dialog box to convert the Adaptive Form container to a new Experience Fragment or add to an existing Experience Fragment appears
On the Convert to Experience Fragment variation dialog box, set values for the following options:
A Submit Action lets you choose the destination of data captured via an Adaptive Form. It is triggered when a user clicks the Submit button on an Adaptive Form. Adaptive forms include some out of the box submit actions. You can also extend a default submit actions to create your own custom submit action. To configure a Submit Action for your form:
You can use the Form Data Model to connect a form to a Data Source to send and receive data based on user actions. You can also connect a form to a JSON schema to receive the submitted data in a pre-defined format.
Before you connect a form to a schema or Form data model
To configure a JSON Schema or Form Data Model for your form:
Open the AEM Page Editor or Experience Fragment that contains the Adaptive Form.
Open the Content Tree, and select the Adaptive Forms Container that hosts your Adaptive Form. An AEM Sites page can host multiple Adaptive Forms. So, carefully select the correct Adaptive Forms Container.
Click the Adaptive Form Container properties icon. The Adaptive Form Container dialog box to configure Data Models opens.
Select and configure a JSON Schema or Form Data Model, based on your requirements. For detailed information about Submit Actions, see Adaptive Form Submit Action.
Click Done.
You can use the prefill service to auto fill fields of an Adaptive Form using existing data. When a user opens a form, the values for those fields are prefilled. You can:
You can use the Form Data Model Prefill service to prepopulate fields of a form using a configured Form Data Model. The Form Data Model Prefill service uses the Get Service of configured Form Data Model to retrieve data. To use Form Data Model Prefill service for an Adaptive Form:
On submission of a form, you can redirect the user to another webpage or a message. To redirect the user or configure the thank you message:
Open the AEM Page Editor or Experience Fragment that contains the Adaptive Form.
Open the Content Tree, and select the Adaptive Forms Container that hosts your Adaptive Form. An AEM Sites page can host multiple Adaptive Forms. So, carefully select the correct Adaptive Forms Container.
Click the Adaptive Form Container properties icon. The Adaptive Form Container dialog box to configure Data Models opens.
Open the Submission tab.
To configure a Redirect URL, for on Submit option, select the Redirect to URL option, and provide an absolute address or a Redirect URL or relative path of an AEM Sites page.
To configure a custom or thank you message, for on Submit option, select the Show Message option, and provide a message in the Message content box. It is a rich text box, you can use the full screen option to view all the available rich text items.