Create a form using Adaptive Forms Block
AEM Forms Edge Delivery provides a block, known as Adaptive Forms Block, to help you easily create forms to capture and store captured data. You can create a new AEM project pre-configured with Adaptive Forms Block or add the Adaptive Forms Block to an existing AEM project.
These forms submit data directly to a Microsoft Excel or Google Sheets file, enabling you to use vibrant ecosystem and robust APIs of Google Sheets, Microsoft Excel, and Microsoft SharePoint to easily process submitted data or to initiate an existing business workflow.
Prerequisites
Before you start, ensure that you have completed the following steps:
- Set up an AEM project using AEM Forms boilerplate or added Adaptive Forms Block to your existing AEM Project and clone the corresponding GitHub repository on your local machine.
In this document, the local folder of your Edge Delivery Services (EDS) project is referred as[EDS Project repository]
. - Ensure that you have access to Google Sheets or Microsoft SharePoint. To set up Microsoft SharePoint as your content source, see How to use SharePoint.
Create a form
Instead of navigating through complex processes, crafting a form can be effortlessly achieved using a spreadsheet. You can define the rows and columns that will make up the form structure. Each row represents an individual form field and the column headers define the corresponding field properties.
For instance, consider the following spreadsheet where rows outline fields for a enquiry
form and column headers define their properties:
To proceed with form creation:
-
Access your AEM Edge Delivery project folder on Microsoft SharePoint or Google Drive.
-
Create a Microsoft Excel Workbook or Google Sheet anywhere within your AEM Edge Delivery project directory. For example, create a spreadsheet named
enquiry
on AEM Edge Delivery project directory on Google Drive. -
Ensure that the sheet is shared with the appropriate AEM user (for example
helix@adobe.com
) as per the configurations specified for your project. Grant the user editing permission for the sheet. -
Open the created spreadsheet and rename the default sheet to “shared-default”.
-
To add the form fields, insert rows and column headers into the ‘shared-default’ sheet. Each row should represent a form field, with column headers defining the corresponding field properties.
For a swift start, consider copying the contents of the Enquiry spreadsheet into your spreadsheet. After copying the content, save your spreadsheet.
embed -
Use AEM Sidekick to preview the sheet.
Upon previewing, new browser tabs display the sheet’s contents in JSON format. Ensure to capture the preview URL, as this is required for rendering the form in next the section. The URL format is as follows:
code language-json https://<branch>--<repository>--<owner>.hlx.live/<form-path>/<form-file-name>.json
<branch>
refers to the branch of your GitHub repository.<repository>
denotes your GitHub repository.<owner>
refers to username of your GitHub account that hosts your GitHub repository.
For example, if your project’s repository is named “portal”, it’s located under the account “wkndforms”, and you’re using the “main” branch, the URL look like the following:
https://main--portal--wkndforms.hlx.page/enquiry.json
Till now, you have prepared the structure of the form. Now, to preview the form:
-
Open your Microsoft SharePoint or Google Drive account and navigate to your AEM Edge Delivery project directory.
-
Open a document file (For example, index file) to embed the form. Alternatively, you can create a new document.
-
Move to the desired location within the document where you intend to add the form.
-
To create a form block to render the form. Select Insert > Table, and create a one column, two row table. Name the table “Form” and paste the preview URL in the second row. Make sure the URL is formatted as a hyperlink, not plain text, as illustrated below:
table 0-row-1 1-row-1 Form https://main–wefinance–wkndforms.hlx.live/enquiry.json This block serves as a placeholder where the form is embedded. In the second row of the block, add the preview URL of your
<form>.json
file as a hyperlink.note important IMPORTANT Ensure that the URL is formatted as a hyperlink rather than being displayed as plain text. -
Use AEM Sidekick to preview the document. The page now displays the form. For example, here is the form based on the enquiry spreadsheet:
Now, fill the form and click the submit button, you experience an error, similar to the following, because the spreadsheet is not set to accept the data yet.
Next step
Prepare your spreadsheet to begin accepting data upon form submission.
See also
- Get started with Edge Delivery Services for AEM Forms
- Create a form using Google Sheets or Microsoft Excel
- Set up your Google Sheets or Microsoft Excel files to start accepting data
- Publish your form and start collecting data
- Customize the look of your forms
- Add repeatable sections to a form
- Show a custom thank you message after form submission
- Adaptive Form Block components and their properties