# Conditional Logic

Canonical: https://useformwork.com/docs/logic/conditional-logic

Show or hide fields and pages using typed, grouped conditions.

Display logic changes what a respondent sees as answers and referenced data change. It can target an individual field or a whole page.

## A simple rule

To show **Company name** only when **Are you applying as a business?** is true:

1. Select **Company name** and open **Display Logic**.
2. Select **Add Display Logic**.
3. Choose **Show this field**.
4. Pick the business toggle as **Field**.
5. Choose **Is true**.

FormWork updates field and page visibility when the entry is created and whenever relevant answers change.

## Show versus hide

- **Show this field/page when…** makes the target hidden unless the conditions match.
- **Hide this field/page when…** makes the target visible unless the conditions match.

Use whichever expresses the business rule most directly. Clear Logic removes the conditional behaviour.

## Rules, groups, and ALL/ANY

Each rule contains:

1. A left-hand **Field/reference**
2. A type-compatible **Condition/operator**
3. A right-hand fixed value or reference, when the operator needs one

Within a group, choose **all** or **any** rules. With multiple groups, choose **all** or **any** groups. This provides two levels of grouping without handwritten expressions.

Example:

```text
Show priority details when ANY group matches:

Group 1 — ALL:
  request_type equals "incident"
  severity greater than or equal to 3

Group 2 — ALL:
  vip_customer is true
```

## Values and references

The picker shows valid reference sources for the context. The comparison value may be a literal or another compatible reference, allowing rules such as **requested amount greater than approved limit**.

Operators are filtered by resolved type:

- Numbers and time values get ordering comparisons.
- Text gets contains, starts/ends, pattern, and format checks.
- Booleans get true/false.
- Repeatable parents get length and empty checks.

See [Operators Reference](/docs/logic/operators) for the full matrix.

## Fields and pages

Field logic is edited from the selected field. Page logic is edited from the page manager. If a page is hidden, client navigation skips it and its controls are not rendered.

Hidden fields retain already-saved answers; hiding is not deletion or data redaction. A Hidden field type cannot itself have display logic, and hidden-only values are not a dependable source for client visibility chains.

## Logic and validation

Required and custom validation apply to the fields that are currently visible. Do not use a hidden required field to intentionally block submission. Test transitions in which a respondent answers a field and then changes an earlier answer that hides it.

## Avoid fragile chains

- Prefer one clear rule over several fields whose visibility depends on each other.
- Do not create circular visibility dependencies.
- Use stable field IDs and the reference picker.
- Put shared business routing in workflows when it does not need to affect the respondent UI.
- Preview every ALL/ANY branch before publishing.

Publish validation checks display logic configuration and reference compatibility. For data-quality checks rather than visibility, use [Validation Rules](/docs/logic/validation-rules).