---
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 [macro expressions](https://docs.kentico.com/13/macro-expressions/macro-syntax.md). Forms support only basic macro expressions, typically of the following types:

- [Form data macros](#form-data-macros)
- [Localization macros](#form-text-localization)

Macros that retrieve values from other various types of advanced contexts may not resolve correctly when the form is submitted by a visitor on the live site.

## Form data macros

When configuring a form, you can use values from the context of the specific form data submitted by the user. This can be achieved using macros in the **{%field\_name%}** format. The _field\_name_ part of the macro is the **Name** of a particular form field, as shown on the **Form builder** tab (not the _Label_ value displayed next to the field in the actual form). When the form is submitted, the macros are automatically resolved and replaced with 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:** _Form submitted 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, for example:

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

To learn more, see:

- [Localizing form fields](https://docs.kentico.com/13/managing-website-content/forms/localizing-form-fields.md)
- [Localizing text fields](https://docs.kentico.com/13/multilingual-websites/setting-up-a-multilingual-user-interface/localizing-text-fields.md)
