> For the complete documentation index, see [llms.txt](https://kb.craftformswp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kb.craftformswp.com/documentation/form-building/create-form/form-settings-post-context/field-links.md).

# Field Links

Field Links update one field when the visitor changes another. Use them to keep two fields showing the same value (a number box and a slider), or to recalculate a field with a formula (convert sizes when the unit changes, keep width and height at a fixed ratio).

![Field Links settings in the CraftForms form editor](https://97821998-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FM2yV1foUgoGHBC66VBDw%2Fuploads%2FpkYrcqc37iZFSn1B3RK0%2Ffield-links--field-links-window.jpg?alt=media)

### What you need

* **CraftForms PRO.** In the free version the Field Links panel shows an upgrade notice.

### Open Field Links

1. Open your form (**CraftForms → Forms → Edit**).
2. In the right sidebar, on the **Form** tab, open **Field Links** and click **Manage Field Links**.

You can also select a field and open **Field Links** in its own settings. It lists the links that field is part of, and **Add a link** opens the window with that field already picked.

### Keep two fields equal

1. Click **+ Keep two fields equal**.
2. Pick the two fields, for example **Length** and **Length slider**.
3. Click **Save Changes**, then **Save** the form.

Changing either field now updates the other.

**Starting value.** Both fields start with the value of the field you picked first. With **Length slider ⇄ Length**, the box starts at the slider's default. To start from the other field's default, pick that field first. A value given in the page address for only one of the two (e.g. `?length=120`) wins.

**Fields that accept different values.** The two fields stay equal within the values both accept. Say the slider goes from 0 to 100 and the number box has a minimum of 10. Moving the slider to 5 sets the box to 10, and the slider moves back to 10. When the steps differ (a slider in steps of 5, a box in steps of 1), both stay on multiples of 5. While the visitor is still typing in the box, only the slider follows; the box is corrected when they leave it, so typing "50" doesn't jump to 10 at the "5". The Field Links window warns when the two fields' ranges differ.

### Set a field with a formula

1. Click **+ Add link**.
2. Choose the field to watch (**When … changes**) and the field to update (**set …**).
3. Write the new value in **Value (expression)**. Click the **Insert field or variable** icon on the right to insert field names and smart variables.
4. Click **Save Changes**, then **Save** the form.

Each link has an **On** switch to pause it, **Duplicate** and **Remove**. **Add reverse link** adds a new link the other way round (the updated field becomes the watched one), with an empty expression for you to fill in.

The expression works like the Price Formula and smart variables: use field names, smart variable names, numbers and functions such as `round()`, `ceil()` and `min()`.

#### Use the value from before the change

`previous.` followed by a name gives the value **just before** the visitor's change. That's what you need to convert from the old unit to the new one.

### Examples

#### Aspect ratio lock

A smart variable `aspect_ratio` holds the ratio (for example 1.7778 for 16:9). Three links:

| When … changes              | Set    | To                                |
| --------------------------- | ------ | --------------------------------- |
| Width                       | Height | `round(width / aspect_ratio, 2)`  |
| Height                      | Width  | `round(height * aspect_ratio, 2)` |
| Aspect ratio (the dropdown) | Height | `round(width / aspect_ratio, 2)`  |

#### Unit conversion

A dropdown `unit` (mm, cm, in) and a conditional smart variable `mm_per_unit` (mm → 1, cm → 10, in → 25.4). Two links:

| When … changes | Set    | To                                                      |
| -------------- | ------ | ------------------------------------------------------- |
| Unit           | Width  | `round(width * previous.mm_per_unit / mm_per_unit, 4)`  |
| Unit           | Height | `round(height * previous.mm_per_unit / mm_per_unit, 4)` |

Switching from cm to in turns 10 cm into 3.937 in, and switching back gives 10 again.

### How links behave

* **Only the visitor's own changes count.** Values filled in from the page address, by Value Presets, when editing a cart item, or by another link don't start a link.
* **One step only.** A value set by a link doesn't set off further links, so two fields linked both ways can't loop. Prices, conditions and smart variables still update as usual.
* **The visitor can still edit the updated field.** A link fires when its field changes. It doesn't lock the other field.
* **Empty values are left alone.** If the watched field, or a field used in the expression, is empty, nothing changes. The same goes for a result that the field can't take, like a choice that isn't in a dropdown.
* **Hidden fields.** A field hidden by Field Conditions is still updated, so it shows the right value when it appears again. While hidden, it's ignored like any hidden field: not in prices, InfoBlocks or the submission. A hidden field also can't start a link.

### Which fields can be linked

Text and number inputs, text areas, dropdowns, radio buttons, checkboxes, color pickers and single-handle range sliders. Not: date pickers, file uploads, signatures, two-handle range sliders, or fields inside a repeater.

For dropdowns, radio buttons and checkboxes, the value must be one of the field's option values.

### Troubleshooting

* **A link does nothing.** Open Field Links and check the row for a red message: a renamed or deleted field, or an error in the expression. Also check that the fields used in the expression aren't empty.
* **I get numbers like 99.9998.** Converting back and forth rounds each time. Round to fewer decimals where it suits you, e.g. `round(…, 2)`.
