Creating a custom adaptive form template creating-a-custom-adaptive-form-template
Prerequisites prerequisites
-
Understanding of AEM Page Template and Adaptive Form Authoring
-
Understanding of AEM Client Side Libraries
Adaptive form template adaptive-form-template
An Adaptive Form template is specialized AEM Page Template, with certain properties and content structure that is used to create Adaptive Form. The template has preconfigured layouts, styles, and basic initial content structure.
Once you create a form, any changes to the original template content structure are not reflected in the form.
Default adaptive form templates default-adaptive-form-templates
AEM QuickStart provides the following adaptive form templates:
- Survey template: Lets you create a single page adaptive form using the Responsive layout that has multiple columns configured. The layout automatically adjusts based on the dimensions of the various screens on which you want to display the form.
- Simple Enrollment template: Lets you create a multi-step adaptive form using a wizard layout. In this layout, you can specify a step completion expression for each step, which is validated before the wizard proceeds to the next step.
- Tabbed Enrollment template: Lets you create a multi-tab adaptive form using a tabs-on-left layout, where you can visit tabs in any random order.
- Advanced Enrollment template: Lets you create a form with mulitple tabs and wizard. It uses a tabs-on-left layout that lets you visit tabs in any order. It uses Adobe Document Cloud esign services for signing and verification.
- Blank Template: Lets you create a form without any header, footer, and initial content. You can add components such as text boxes, buttons, and images. The blank template lets you create a form that you can embed in AEM Site pages.
These templates have the sling:resourceType
property set to the corresponding page component. The page component renders the CQ page, containing adaptive form container, which in turn renders adaptive form.
The following table enumerates the association between templates and page component:
Creating an adaptive form template using template editor creating-an-adaptive-form-template-using-template-editor
You can specify the structure and initial content of an adaptive form using Template Editor. For example, you want all form authors to have few text boxes, navigation buttons, and a submit button in an enrollment form. You can create a template that authors can use to create a form that is consistent with other enrollment forms. AEM Template Editor lets you:
- Add header and footer components of a form in the structure layer
- Provide the initial content for the form.
- Specify a theme.
- Specify actions such as submit, reset, and navigate.
For more informtion, see Template Editor.
Creating an adaptive form template from CRXDE creating-an-adaptive-form-template-from-crxde
Instead of using the available templates, you can create a template and use it to create adaptive forms. Custom templates are based on various page components that reference adaptive form containers and page elements, such as header and footer.
You can create these components using the base page component for your website. Alternatively, you can extend the page component of the adaptive form that out of the box templates use.
Perform the following steps to create a custom template, such as simpleEnrollmentTemplate.
-
Navigate to CRXDE Lite on your authoring instance.
-
Under the /apps directory, create the folder structure for your application. For example, if the application name is mycompany, create a folder with this name. Typically, the application folder contains components, configuration, templates, src, and installation directories. For this example, create the components, configuration, and templates folders.
-
Navigate to the folder /libs/fd/af/templates.
-
Copy the
simpleEnrollmentTemplate
node. -
Navigate to the folder /apps/mycompany/templates. Right-click it and select Paste.
-
If necessary, rename the template node you copied. For example, rename it as enrollment-template.
-
Navigate to the location /apps/mycompany/templates/enrollment-template.
-
Modify the
jcr:title
andjcr:description
properties for thejcr:content
node to distinguish the template from the template you copied. -
The
jcr:content
node of the modified template contains theguideContainer
andguideformtitle
components.guideContainer
is the container that holds the adaptive form. Theguideformtitle
component displays the application name, description, and so on.Instead of
guideformtitle
, you can include a custom component or theparsys
component. For example, removeguideformtitle
, and add a custom component or theparsys
component node. Ensure that thesling:resourceType
property of the component references the component and the same is defined in the pagecomponent.jsp
file. -
Navigate to the location /apps/mycompany/templates/enrollment-template/jcr:content.
-
Open the Properties tab and change the value of the
cq:designPath
property to /etc/designs/mycompany. -
Now create a /etc/designs/mycompany node for the
cq:Page
type.
Create an adaptive form page component create-an-adaptive-form-page-component
The custom template has the same styling as the default template because the template references the page component /libs/fd/af/components/page/base. You can find the component reference as the property sling:resourceType
defined at the node /apps/mycompany/templates/enrollment-template/jcr:content. Because base is a core product component, do not modify this component.
-
Navigate to the node /apps/mycompany/templates/enrollment-template/jcr:content and modify the value of the property
sling:resourceType
to /apps/mycompany/components/page/enrollmentpage -
Copy the node /libs/fd/af/components/page/base to the folder /apps/mycompany/components/page.
-
Rename the copied component to
enrollmentpage
. -
(Only if you already have a contentpage) Perform the following steps (a-d), if you have an existing
contentpage
component for your website. If you do not have an existingcontentpage
component for your website, you can leave theresourceSuperType
property to point to the OOTB base page.-
For the
enrollmentpage
node, set value of the propertysling:resourceSuperType
to mycompany/components/page/contentpage. Thecontentpage
component is the base page component for your site. Other page components can extend it. Remove script files underenrollmentpage
, excepthead.jsp
,content.jsp
, andlibrary.jsp
. Thesling:resourceSuperType
component, which iscontentpage
in this case, includes all such scripts. Headers, including navigation bar and footer are inherited from thecontentpage
component. -
Open the file
head.jsp
.The JSP file contains the line
<cq.include script="library.jsp"/>
.The
library.jsp
file contains theguide.theme.simpleEnrollment
client library, which contains the styling for the adaptive form.The page component
enrollmentpage
has an exclusivehead.jsp
file that overrides thehead.jsp
file of thecontentpage
component. -
Include all scripts in the
head.jsp
file for thecontentpage
component to thehead.jsp
file for theenrollmentpage
component. -
In the
content.jsp
script, you can add additional page content or references to other components that are included when a page renders. For example, if you add the custom componentapplicationformheader
, ensure that you add the following reference to the component in the JSP file:<cq:include path="applicationformheader" resourceType="mycompany/components/applicationformheader"/>
Similarly, if you add a
parsys
component in the template node structure, also include the custom component.
-
Creating an adaptive form client library creating-an-adaptive-form-client-library
The head.jsp
file of the enrollmentpage
component for the new template includes a client library guide.theme.simpleEnrollment
. The default template also uses this client library. Change the style in the new template using on of these methods:
- Define a custom theme and replace the default theme
guide.theme.simpleEnrollment
with the custom theme. - Define a new client library under /etc/designs/mycompany. Include the client library after the default theme entry in the jsp page. Include all overridden styles and additional Java Script files in this client library.