---
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).

When configuring forms, you can set values dynamically using various types of [macro expressions](https://docs.kentico.com/k12sp/macro-expressions/macro-syntax.md), for example based on the values submitted in the form's fields. The following table shows which macro types you can use for particular form configuration values.

|                                     | Localization | General (K#) | Query string | Cookie | Path | Form data macros |
| ----------------------------------- | ------------ | ------------ | ------------ | ------ | ---- | ---------------- |
| 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           |              |              |              |        |      |                  |
| Email notification tab – all fields |              |              |              |        |      |                  |
| Autoresponder tab – all fields      |              |              |              |        |      |                  |

> **Note:** **Forms on MVC sites**
>
> For forms on content-only (MVC) sites, you can only use basic macro expressions, such as form data macros or localization macros. Macros that retrieve values from various types of contexts may not resolve correctly when the form is submitted on your content-only site.

## Form data macros

You can use values from current context when configuring a form. This can be achieved using a data macro in the **{%field\_name%}** format. The _field\_name_ part of the macro is the **Field name** value of a particular form field. 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
- **Email notifications**
  - Sender email
  - Recipient emails
  - Subject
  - Email body
- **Autoresponder emails**
  - From email
  - Subject
  - Email body

#### Example 1

When configuring notification emails for a form, you may use the following values:

- **Subject:** _Event registration by {%FirstName%} {%LastName%}_

_FirstName_ and _LastName_ are the names of fields in the form. As a result, the notification email subjects will contain the first and last name submitted by the user in the related form record.

#### 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 multilingual 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 [Localizing text fields](https://docs.kentico.com/k12sp/multilingual-websites/setting-up-a-multilingual-user-interface/localizing-text-fields.md).
