Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions datapress/Forms/custom-forms/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"label": "Custom Forms",
"position": 1,
"link": {
"type": "generated-index"
}
}
137 changes: 137 additions & 0 deletions datapress/Forms/custom-forms/custom-forms-example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
title: Custom Forms examples
sidebar_position: 9
slug: /forms/custom-forms-example
tags:
- Form
- DataPress
keywords: [DataPress custom form]
---

:::note
The plugin previously known as **Dataverse Integration** has been renamed to **DataPress**. All references in documentation and UI are being updated accordingly. [1](https://docs.alexacrm.com/forms/custom-forms/)
:::

## Custom form examples

### 1. Update a Contact

```
{% form entity="contact" mode="update" record=record|to_entity_reference %}
<form>
<div class="form-group">
<label>First Name:
<input class="form-control" name="firstname" value="{{ record['firstname'] }}">
</label>
</div>
<div class="form-group">
<label>Last Name:
<input class="form-control" name="lastname" value="{{ record['lastname'] }}">
</label>
</div>
<div class="form-group">
<label>Email:
form-control" name="emailaddress1" value="{{ record['emailaddress1'] }}">
</label>
</div>
<div class="form-group">
<label>Phone:
<input class="form-control" name="telephone1" value="{{ record['telephone1'] }}">
</label>
</div>
<button type="submit" class="btn btn-primary">Send</button>
</form>
{% endform %}
```

### 2. Contact Us Form (Create) + reCAPTCHA

```
{% form entity="lead" mode="create" recaptcha=true %}
<form>
<div class="form-group">
<label>First Name:
<input class="form-control" name="firstname">
</label>
</div>
<div class="form-group">
<label>Last Name:
<input class="form-control" name="lastname">
</label>
</div>
<div class="form-group">
<label>Email:
<input class="form-control" name="emailaddress1">
</label>
</div>
<div class="form-group">
<recaptcha></recaptcha>
</div>
<button type="submit" class="btn btn-primary">Send</button>
</form>
{% endform %}
```

### 3. Date Only & Date Time fields

```
{% form entity="contact" mode="create" %}
<form>
<div class="form-group">
<label>Account Name:
<input class="form-control" name="name">
</label>
</div>
<div class="form-group">
<label>Date Only:
<input class="vdatetime" name="cr1d1_dateonly">
</label>
</div>
<div class="form-group">
<label>Date Time:
<input class="vdatetime" name="cr1d1_datetime">
</label>
</div>
<button type="submit" class="btn btn-primary">Send</button>
</form>
{% endform %}
```

### 4. Display extracted date/time values

```
<div class="form-group">
<label>UTC Date:
<input class="form-control" name="cr1d1_datetime_utc_date" value="{{ currentRecord['cr1d1_datetime_utc_date'] }}">
</label>
</div>
<div class="form-group">
<label>Local Date:
<input class="form-control" name="cr1d1_datetime_local_date" value="{{ currentRecord['cr1d1_datetime_local_date'] }}">
</label>
</div>
<div class="form-group">
<label>UTC Time:
<input class="form-control" name="cr1d1_datetime_utc_time" value="{{ currentRecord['cr1d1_datetime_utc_time'] }}">
</label>
</div>
<div class="form-group">
<label>Local Time:
<input class="form-control" name="cr1d1_datetime_local_time" value="{{ currentRecord['cr1d1_datetime_local_time'] }}">
</label>
</div>
```
64 changes: 64 additions & 0 deletions datapress/Forms/custom-forms/custom-forms-overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: Custom Forms - Overview
sidebar_position: 7
slug: /forms/custom-forms-overview
tags:
- Form
- DataPress
keywords: [DataPress custom form]
---

:::note
The plugin previously known as **Dataverse Integration** has been renamed to **DataPress**. All references in documentation and UI are being updated accordingly. [1](https://docs.alexacrm.com/forms/custom-forms/)
:::

<p class="lead">Use Twig + HTML to build custom forms and send submissions directly into Dataverse.</p>

# Overview

Custom Forms let you capture data from your WordPress site **without** using Power Apps or Dynamics 365 forms.
Instead, you build the layout yourself using regular HTML form markup and wrap it inside Twig tags.

Key capabilities:
- Build any HTML layout using your own design.
- Map form fields to Dataverse table columns via input `name` attributes.
- Submit data directly into Dataverse (create or update records).
- Optionally add reCAPTCHA protection.

Custom Forms are included in the **free** DataPress plugin on WordPress.org.

---

# Configuration

## 1. Wrap your HTML form with `{% form %} ... {% endform %}`

A custom form begins with a pair of Twig tags:
`{% form ... %}` → configuration
`{% endform %}` → closing tag

Inside them, you **must** place a standard HTML `<form>...</form>` element.
The submit event is handled automatically when the user submits the form.

## 2. Connect form inputs to Dataverse columns

Use the Dataverse column logical name for each `<input>`:

```html
<input name="firstname">
<input name="emailaddress1">
```

The plugin uses these names to map the values to Dataverse.

## 3. Enable reCAPTCHA (optional)

To protect from spam:

- Add recaptcha=true to `{% form %}`.
- Add the placeholder `<recaptcha>` inside your `<form>`.
- Configure reCAPTCHA keys in plugin settings — otherwise the form may not load or submit.

## 4. Place the form on a WordPress page

Use the Gutenberg block **Dataverse Plain**, which accepts Twig and renders it as HTML on the frontend.
96 changes: 96 additions & 0 deletions datapress/Forms/custom-forms/custom-forms-reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
title: Custom Forms - Reference
sidebar_position: 8
slug: /forms/custom-forms-reference
tags:
- Form
- DataPress
keywords: [DataPress custom form]
---

# Reference (Capabilities & Limitations)

## What Custom Forms can do

- **Create** new Dataverse records (rows) from a WordPress page.
- **Update** existing Dataverse records when `mode="update"` and `record` is provided.
- Map HTML inputs to Dataverse columns using the input `name` attribute (Dataverse logical column name).
- Optionally enable **reCAPTCHA** [protection for custom forms](https://docs.alexacrm.com/forms/recaptcha/)

## How submission works (important note)

DataPress processes submissions using the HTML form **submit** event (standard browser behavior). [1](https://docs.alexacrm.com/forms/custom-forms/)[3](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit_event)

Make sure your markup contains a real `<form>...</form>` element, because [submission is tied to the form itself](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit_event)

---

## `{% form %}` parameters

Use these parameters in the opening Twig tag:


| Parameter | Type | Description |
|-------------|---------------------|-------------|
| **entity** | string (required) | Logical name of the target Dataverse table. |
| **mode** | string (required) | Form mode: `create` to create a new record, `update` to update an existing one. |
| **record** | EntityReference | Record GUID, EntityReference, or Table object used in `update` mode.|
| **recaptcha** | boolean | Enables reCAPTCHA validation. Requires `<recaptcha>` placeholder inside the form. See *Protect form submissions with reCAPTCHA*. |
| **redirect** | string | URL to redirect the user to after a successful submission. Supports `%s` for record GUID. |
| **message** | string | Custom success message displayed after form submission. |
| **messages** | object | Custom messages object (e.g., success / failure messages). Example: `{ "success": "Thanks!", "failure": "Please try again later." }` |
| **keep** | boolean | Keeps the form visible after a successful submission (`false` by default; form collapses). |
| **keep_data** | boolean | Keeps form field values after a successful submission (`false` by default; values are cleared). |

[Examples](/forms/custom-forms-example)

---

## Premium behavior (Power Apps forms)

If the premium add‑on is installed and an `id` parameter is used, the `{% form %}` tag behaves like a Power Apps form [tag](/forms/forms-configuration/)

---

## reCAPTCHA requirements (Custom Forms)

If you enable reCAPTCHA with `recaptcha=true`, you must do **both**:

1. Configure [reCAPTCHA keys in DataPress settings](/forms/recaptcha/)
2. Add the `<recaptcha>` placeholder **inside** your `<form>` markup.
DataPress replaces it with the actual reCAPTCHA widget at runtime.

If reCAPTCHA is enabled but not configured, the form may fail to render or submit.

Read more: [reCAPTCHA support](/forms/recaptcha/)

---

## Date/Time fields in Custom Forms

### Expected input formats

When you fill date fields manually in a custom form, use these formats:

- **Date Only**: `yyyy-mm-dd` or `yyyy/mm/dd`
Example: `2023-01-20` or `2023/01/20` [1](https://docs.alexacrm.com/forms/custom-forms/)
- **Date Time**: `yyyy-mm-ddThh:mm`
Example: `2023-01-20T12:30` [1](https://docs.alexacrm.com/forms/custom-forms/)

### Time zone behavior

How date/time values are displayed can depend on Dataverse behavior (User Local / Time Zone Independent / Date Only) and DataPress settings such as [`ICDS_DATETIME_VALUE`](/date-and-time/)
[1](https://learn.microsoft.com/en-us/power-apps/maker/data-platform/behavior-format-date-time-field)

Read more: [Date and Time columns](https://docs.alexacrm.com/date-and-time/)

---

## Getting the created record GUID via redirect

After a record is created successfully, you can capture its GUID using `redirect` with a `%s` placeholder.

Example:

- `redirect="/?id=%s"` becomes:
`/?id=00000000-0000-0000-0000-000000000000`
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Custom Forms
sidebar_position: 2
title: Custom Forms - old
sidebar_position: 6
slug: /forms/custom-forms
tags:
- Form
Expand Down
17 changes: 17 additions & 0 deletions datapress/Forms/elementor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Elementor
sidebar_label: Elementor
slug: /forms/elementor
sidebar_position: 5
---

import React from 'react';
import {useHistory} from '@docusaurus/router';

export default function Redirect() {
const history = useHistory();
React.useEffect(() => {
history.replace('/addons/elementor/');
}, []);
return null;
}
Loading