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
simpleEnrollmentTemplatenode. -
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:titleandjcr:descriptionproperties for thejcr:contentnode to distinguish the template from the template you copied. -
The
jcr:contentnode of the modified template contains theguideContainerandguideformtitlecomponents.guideContaineris the container that holds the adaptive form. Theguideformtitlecomponent displays the application name, description, and so on.Instead of
guideformtitle, you can include a custom component or theparsyscomponent. For example, removeguideformtitle, and add a custom component or theparsyscomponent node. Ensure that thesling:resourceTypeproperty of the component references the component and the same is defined in the pagecomponent.jspfile. -
Navigate to the location /apps/mycompany/templates/enrollment-template/jcr:content.
-
Open the Properties tab and change the value of the
cq:designPathproperty to /etc/designs/mycompany. -
Now create a /etc/designs/mycompany node for the
cq:Pagetype.
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:resourceTypeto /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
contentpagecomponent for your website. If you do not have an existingcontentpagecomponent for your website, you can leave theresourceSuperTypeproperty to point to the out-of-the-box base page.-
For the
enrollmentpagenode, set value of the propertysling:resourceSuperTypeto mycompany/components/page/contentpage. Thecontentpagecomponent 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:resourceSuperTypecomponent, which iscontentpagein this case, includes all such scripts. Headers, including navigation bar and footer are inherited from thecontentpagecomponent. -
Open the file
head.jsp.The JSP file contains the line
<cq.include script="library.jsp"/>.The
library.jspfile contains theguide.theme.simpleEnrollmentclient library, which contains the styling for the adaptive form.The page component
enrollmentpagehas an exclusivehead.jspfile that overrides thehead.jspfile of thecontentpagecomponent. -
Include all scripts in the
head.jspfile for thecontentpagecomponent to thehead.jspfile for theenrollmentpagecomponent. -
In the
content.jspscript, 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
parsyscomponent 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.simpleEnrollmentwith 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.