Adobe Experience Manager (AEM) forms can help you transform complex transactions into simple, delightful digital experiences. However, it requires concerted effort to implement, build, execute, and maintain an efficient and productive AEM Forms ecosystem.
This document provides guidelines and recommendations that forms administrator, authors, and developers can benefit from when working with AEM Forms, especially adaptive forms component. It discusses best practices right from setting up a forms development project to configuring, customizing, authoring, and optimizing AEM Forms. These best practices collectively contribute to the overall performance of AEM Forms ecosystem.
In addition, here are some recommended reads for general AEM best practices:
A simplified and standardized project structure can significantly reduce development and maintenance efforts. Apache Maven is an open source tool recommended for building AEM projects.
Use Apache Maven aem-project-archetype
to create and manage structure for AEM project. It creates recommended structure and templates for your AEM project. Also, it provides build automation and change control systems to help manage the project.
archetype:generate
command to generate the initial structure.eclipse:eclipse
command to generate the eclipse project files and import the project into eclipse.For more information, see How to Build AEM Projects using Apache Maven.
The FileVault tool or VLT helps you map the content of a CRX or AEM instance to your file system. It provides change control management operations, such as check-in and check-out of the AEM project content. See How to use the VLT Tool.
If you use Eclipse-integrated development environment, you can use AEM Developer tools for seamless integration of Eclipse IDE with AEM instances to create AEM applications. For details, see AEM developer tools for Eclipse.
Once you have your AEM project set up, define strategy for authoring and customizing adaptive forms templates and components.
An adaptive form template is a specialized AEM page that defines structure and the header-footer information of an adaptive form. A template has preconfigured layouts, styles, and basic structure for an adaptive form. AEM Forms provides out-of-the-box templates and components that you can use to author adaptive forms. However, you can create custom templates and components as per your requirements. It is recommended to gather requirements for additional templates and components you will need in your adaptive forms. For details, see Customizing adaptive forms and components.
AEM Forms allows you to create adaptive forms based on the following form models. The form models act as interface for data exchange between a form and AEM system and provide an XML-based structure for data flow within and outside an adaptive form. Also, the form models impose rules and constraints on adaptive forms in the form of schema and XFA constraints.
It is important to carefully choose the data model that not only suits your requirements but extends your existing investments in XFA and XSD assets, if any. It is recommended to use XSD Model to create form templates because the generated XML contains data as per XPATH defined by schema. Using XSD Model as a default choice for Form Data Model also helps because it decouples form design from back end system that processes and consumes data and it improves the performance of form because of one to one mapping of form field. Also, BindRef of the field can be made the XPATH of its data value in XML.
For more information, see Create an adaptive form.
AEM Forms provides out-of-the-box adaptive form templates that you can use to create adaptive forms. You can also create your own templates. AEM provides static and editable templates.
For styling a specific field or panel instance, use inline styling. Alternatively, you can define a class in a CSS file and specify the class name in the CSS Class property of the component.
Include a client library in a component to consistently apply styles across adaptive forms or fragments that use that component. For more information, see Create an adaptive form page component.
Apply styles defined in a client library to select adaptive forms by specifying the path to the client library in the CSS file path field in the adaptive form container properties.
To create a client library of your styles, you can configure the custom CSS file in the Theme Editor base clientlib or in the Form Container properties.
Adaptive forms provide panel layouts, such as responsive, tabbed, accordions, and wizard, to control how form components are laid out in a panel. You can create custom panel layouts and make them available for use by form authors. For more information, see Creating custom layout components for adaptive forms.
You can also customize specific adaptive form components like fields and panel layout.
See Handling personally identifiable information for recommendations on handling PII data.
Use Objects browser in the sidebar to quickly access fields deep down in the form hierarchy. You can use the search box to search for objects in the form or objects tree to navigate from one object to another.
To view and edit the properties of a component in the components browser in the sidebar, select the component and click . You can also double-click a component to view its properties in the properties browser.
Use keyboard shortcuts to take quick actions on your forms. See AEM Forms Keyboard Shortcuts.
Adaptive form components are recommended for use only in adaptive form pages. The components have dependency on their parent hierarchy. Hence, do not use them in an AEM page.
Also, see component descriptions and best practices in Introduction to authoring adaptive forms.
AEM Forms provides a rule editor that allows you to create rules to add dynamic behavior to adaptive form components. Using these rules, you can evaluate conditions and trigger actions on components, such as show or hide fields, calculate values, change drop-down list dynamically, and so on.
Rule editor provides a visual editor and a code editor for writing rules. Consider the following when writing rules using the code editor mode:
Use meaningful and unique names for form fields and components to avoid any possible conflicts while writing rules.
Use this
operator for a component to refer to itself in a rule expression. It ensures that the rule remains valid even if the component name changes. For example, field1.valueCommit script: this.value > 10
.
Use component names when referring to other form components. Use the value
property to fetch the value of a field or component. For example, field1.value
.
Refer components by relative unique hierarchy to avoid any conflict. For example, parentName.fieldName
.
When handling complex or commonly-used rules, consider writing business logic as functions in a separate client library that you can specify and reuse across adaptive forms. The client library should be a self-contained library and should not have any external dependencies, except on jQuery and Underscore.js. You can also use the client library to enforce server-side revalidation of submitted form data.
Adaptive forms provide a set of APIs that you can use to communicate with and perform actions on adaptive forms. Some of the key APIs are as follows. For more information, see JavaScript Library API reference for Adaptive Forms.
guideBridge.reset()
: Resets a form.
guideBridge.submit()
: Submits a form.
guideBridge.setFocus(somExp, focusOption, runCompletionExp)
: Sets focus to a field.
guideBridge.validate(errorList, somExpression, focus)
: Validates a form.
guideBridge.getDataXML(options)
: Gets form data as XML.
guideBridge.resolveNode(somExpression)
: Gets a form object.
guideBridge.setProperty(somList, propertyName, valueList)
: Sets property of a form object.
In addition, you can use the following field properties:
field.value
to change value of a field.ield.enabled
to enable/disable a field.field.visible
to change visibility of a field.Adaptive form authors may need to write JavaScript code to build business logic in a form. While JavaScript is powerful and effective, it is likely that it could compromise on security expectations. Therefore, you must ensure that the form author is a trusted persona and there are processes to review and approve the JavaScript code before a form is put into production. Administrator can restrict the access to rule editor access to user groups based on their role or function. See Grant rule editor access to select user groups.
You can use expressions in rules to make adaptive forms dynamic. All the expressions are valid JavaScript expressions and use adaptive forms scripting model APIs. These expressions return values of certain types. For more information about expressions and best practices around them, see Adaptive form expressions.
Adaptive for themes allow you to create reusable styles that can be applied across forms for consistent look and styling. It is recommended to use Themes to define styling for form components and panels. Some best practices around themes are as follows:
For more information, see Themes.
Form authors and end users typically face performance issues when loading large forms in authoring mode or at runtime. As number of objects (fields and panels) in form increases, the authoring and runtime experience starts degrading. It also prevents multiple authors to collaborate and author a form simultaneously.
Consider the following best practices to overcome performance issues with large forms:
It is recommended to create adaptive forms using XSD form data model even when converting an XFA to adaptive form, if possible.
Include only those fields and panels in adaptive forms that capture information from the user. Consider keeping static content minimal or use URLs to open them in a separate window.
While every form is designed for a specific purpose, there are some common segments in most forms. For example, personal details, address, employment details, and so on. Create adaptive form fragments for common form elements and sections and use them across forms. You can also save a panel in an existing form as a fragment. Any change in a fragment is reflected in all associated adaptive forms. It promotes collaborative authoring as multiple authors can work simultaneously on different fragments that make up a form.
Use Save and Resume with auto-save to save the adaptive form periodically and enable users to revisit later to complete the form.
Configure fragments to load lazily. At runtime, fragment marked to load lazily are rendered only when they are required. It significantly reduces the load time for large forms. It is also supported in fragments with repeatable panels. For more information, see Configure lazy loading.
You can prefill adaptive form fields with data fetched from backend to help users quickly fill the form and avoid typing mistakes.
AEM Forms provides a prefill service to read data from a pre-defined data XML file and prefill the fields of an adaptive form with the content in the prefill XML file.
The prefill data XML must be compliant with the schema of the form model associated with the adaptive form.
Include afBoundedData
and afUnBoundedData
sections in the prefill XML to prefill both bound and unbound fields in an adaptive form.
For adaptive forms based on form data model, AEM Forms provides out-of-the-box Form Data Model Prefill Service. The prefill service queries data sources for data model objects in the adaptive form and prefills field values when rendering the form.
You can also use the file, crx, service, or http protocols prefill adaptive forms.
AEM Forms supports custom prefill services that you can plug in as an OSGi service to prefill adaptive forms.
For more information, see Prefill adaptive form fields.
Adaptive forms require Submit actions to process user-specified data. A Submit action determines the task performed on the data that you submit using an adaptive form.
You can leverage multi-sign experience of Acrobat Sign in adaptive forms. Consider the following when configuring Acrobat Sign in adaptive forms. For details, see Using Acrobat Sign in an adaptive form.
A document of record (DoR) is a flattened PDF version of an adaptive form that you can print, sign, or archive.
Depending on the form data model an adaptive form is based on, you can configure a template for DoR as follows:
Configure header, footer, images, color, font, and so on right from the Document of Record tab of the adaptive form editor.
Use DoRService
to generate the DoR programmatically.
Exclude hidden fields from the DoR.
Use afAcceptLang
request parameter to view DoR in another locale.
AEM Chrome Plug-in is a browser extension for Google Chrome that provides tools for debugging adaptive forms. Form authors and developers can use these tools to:
For more information, see AEM Chrome Plug-in - Adaptive Form.
Calvin SDK is a utility API for Adaptive Forms developers to test Adaptive Forms. Calvin SDK is built on top of the Hobbes.js testing framework. You can use the framework to test the following:
For more information, see Automate testing of adaptive forms.
Server-side validations are required to prevent any attempts to bypass validations on the client and any possible compromise of data submissions and business rules violations. Server-side validations are executed on server by loading the required client library.
AEM provides translation workflows that you can use to localize adaptive forms. For information, see Using AEM translation workflow to localize adaptive forms.
Some best practices when localizing adaptive forms are as follows:
Use adaptive form fragments for common elements across forms and localize fragments. It ensures that you localize a fragment once and it reflects in all forms where the localized fragment is used.
Any modifications like adding a new component or applying a script in a localized form are not localized automatically. Therefore, you must finalize a form before localizing it to avoid multiple localization cycles.
Use afAcceptLang
request parameter to override the browser locale and render the form in the specified locale. For example, the following URL will force to render the form in Japanese locale, irrespective of the locale specified in the browser setting:
https://[*server*]:[*port*]/<*contextPath*>/<*formFolder*>/<*formName*>.html?wcmmode=disabled&afAcceptLang=ja
AEM Forms currently supports localization of adaptive forms content in English (en), Spanish (es), French (fr), Italian (it), German (de), Japanese (ja), Portuguese-Brazilian (pt-BR), Chinese- (zh-CN), Chinese-Taiwan (zh-TW), and Korean (ko-KR) locales. However, you can add support for new locales for adaptive forms at runtime. For more information, see Supporting new locales for adaptive forms localization.
You can configure an additional instance of AEM Forms server that resides behind the firewall in a secured zone. You can use this instance for:
You often need to move your AEM projects from one environment to another. Some of the key things to remember when moving are as follows:
Some best practices to configure AEM to improve the overall performance are as follows:
Enable HTML client library compression for JavaScript and CSS from Felix Console.
Cache all client libraries at /etc.clientlibs/fd
and any additional custom client libraries on AEM dispatcher to increase the responsiveness and security of your published forms. For more information, see Dispatcher.
Do not cache /content/forms/af/
and /content/dam/formsanddocuments/*
paths. for detailed information about configuring adaptive forms caching, see Caching adaptive forms.
Enable HTML via web server compression module. For more information, see Performance tuning of AEM Forms server.
Increase calls per request configuration for large forms. See Optimizing performance of large and complex forms.
Secure AEM Forms server.
nosamplecontent
run mode to ensure there are no sample content and sample users deployed on the production server. See Running AEM in Production Ready Mode.Keep the heap size to a minimum of 8 GB. For other settings, see Performance tuning of AEM Forms server.
Use service user sessions instead of admin sessions for executing service-level tasks. For more information, see Service authentication.
In a production environment, it is recommended not to store submitted form data in AEM repository. The default implementation of Forms Portal Store, Store Content, and Store PDF submit actions store form data in AEM repository. These submit actions are meant only for demonstration purposes. Also, the Save and Resume and Auto Save features use portal storage by default. Therefore, consider the following recommendations:
Storing draft data: If you are using the Draft feature of adaptive forms, you should implement a custom Service Provide Interface (SPI) to store draft data in more secure storage like database. For more information, see Sample for integrating drafts & submissions component with database.
Storing submission data: If you are using Form Portal Submit Store, you should implement a custom SPI to store submission data in a database. See Sample for integrating drafts & submissions component with database for a sample integration.
You can also write a custom submit action that stores form data and attachment in secure storage. See Writing custom Submit action for adaptive forms for more information.
One of the key challenges for organizations is how to handle personally identifiable (PII) data. Some best practices that will help you handle such data are as follows: