---
title: Using macros with forms
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

Values of the fields that you need to fill in when configuring a form can be obtained dynamically from the submitted values in form fields. The following table shows which macro types you can use for particular values of form configuration.

|                                      | Localization | Context | Query String | Cookie | Custom | Path | Context (Data) macros |
| ------------------------------------ | ------------ | ------- | ------------ | ------ | ------ | ---- | --------------------- |
| General tab - Form display name      |              |         |              |        |        |      |                       |
| General tab - Display text           |              |         |              |        |        |      |                       |
| General tab - Redirect to URL        |              |         |              |        |        |      |                       |
| General tab - Submit button text     |              |         |              |        |        |      |                       |
| Fields tab - Default value           |              |         |              |        |        |      |                       |
| Fields tab - Field caption           |              |         |              |        |        |      |                       |
| Fields tab - Table layout            |              |         |              |        |        |      |                       |
| Notification e-mail tab - all fields |              |         |              |        |        |      |                       |
| Autoresponder tab - all fields       |              |         |              |        |        |      |                       |

## Context (data) macros

You can use values from current context when configuring a form. This can be achieved using a data macro in the **{%column\_name%}** format. The _column\_name_ part of the macro is the value of the **Column name** property of a particular form filed. When the form is submitted, the macros are automatically resolved and replaced with particular data from the form.

These macros can be used in the following text fields:

- **General tab**
  - Display text
  - Redirect to URL
- **Notification e-mails**
  - From e-mail
  - To e-mail
  - Subject
  - E-mail body
- **Autoresponder e-mails**
  - From e-mail
  - Subject
  - E-mail body

#### Example 1

When configuring notification e-mails for a form, you may use the following values:

- **From e-mail:** _{%Email%}_;
- **Subject:** _Event registration by {%FirstName%} {%LastName%}_;

_Email_, _FirstName_ and _LastName_ are the column names of the defined form's fields.

This will result in the e-mail having the user's e-mail address as the sender address, which enables the recipient to easily reply to the e-mail. The subject of the e-mail will have the first and last name of the user, which will help identifying the sender of the e-mail.

#### Example 2

If you enter the **Display text** value on the **General** tab of the form like this:

- _Dear {%FirstName%}, thank you for your message. We will contact you shortly._

The text will be resolved as the following when "Jane" was entered in the **First name** field by the user:

- _Dear Jane, thank you for your message. We will contact you shortly._

## Form text localization

If you need to display the form on a multi-lingual website, you can localize field captions and other text strings using localization macros, e.g.:

- {$myform.fullname$}
- {$=Hello|de-de=Hallo|it-it=Ciao$}

You can find more details in [Working with resource strings](https://docs.kentico.com/k8/multilingual-websites/setting-up-a-multilingual-user-interface/working-with-resource-strings.md).

Detailed overview of all macros in Kentico can be found in [Macro expressions.](https://docs.kentico.com/k8/macro-expressions.md)
