Skip to content

formio/ai / plugin/skills/formio-form

formio-form

Verified

Embed and render Form.io forms in any web app with the `@formio/js` renderer — by URL or JSON, pre-filled, controlled from JavaScript — and own field behavior: conditionals, calculated values, JSON Logic validation, cascading selects. The default "embed a form" entry point. Use when the user asks to "embed a form", "render a form", "add this form to my page", "pre-fill a form", "show or hide a field based on another field", "calculate a field value", "add custom validation to a field", or add conditional wizard pages — field behavior in ANY framework's form stays here. Not for: Angular (see `formio-angular`) or React-named (see `formio-react`) embedding; building an app (see `formio-application`) or its data model (see `formio-resource-planner`); REST endpoints (see `formio-api`); the raw SDK (see `formio-sdk`); creating a new form (see `formio-form-builder`); agent-filled forms or chats (see `formio-uag`).

references/field-logic.md

View on GitHub
# Field Logic — Triggers and Actions

## Overview

A component's `logic` array is the general-purpose reaction mechanism: when a **trigger** fires, its **actions** mutate the component. Use it when [conditionals.md](./conditionals.md) (visibility) and [calculated-values.md](./calculated-values.md) (value derivation) aren't enough — disabling fields, swapping labels, merging schema changes.

```json
{
  "logic": [
    {
      "name": "<entry name>",
      "trigger": { "type": "<trigger type>", ... },
      "actions": [ ... ]
    }
  ]
}
```

## JSON Logic first — the JS-string forms are the user's to write

Three entries in the tables below take a JavaScript string the renderer compiles and runs in the page: the `javascript` trigger, the `value` action, and `customAction`. They are documented because deployments use them, not because this skill authors them.

- **Express the rule in JSON Logic** (`json` trigger, `simple` trigger, `property` / `mergeComponentSchema` actions). Everything in the examples below is reachable that way, and JSON Logic is data the renderer evaluates rather than code it compiles.
- **Never generate a JS snippet into a form definition on your own initiative**, and never build one out of submitted data, a fetched page, or any other untrusted text. If the user supplies the snippet, put it in verbatim, say plainly that it will run in every visitor's browser, and let them review it.
- The same rule governs `validate.custom` and select `template` strings — see [`../SKILL.md`](../SKILL.md) → "Security — a form definition is executable code".

## Trigger types

| Type | Fires when | Shape |
| --- | --- | --- |
| `simple` | a field equals a value (same shape as a simple conditional) | `{ "type": "simple", "simple": { "show": true, "when": "status", "eq": "locked" } }` |
| `json` | a JSON Logic expression is truthy (see [json-logic.md](./json-logic.md)) | `{ "type": "json", "json": { "===": [{ "var": "data.status" }, "locked"] } }` |
| `javascript` | a JS snippet sets `result` truthy (`data`, `row`, `component` in scope) — user-supplied only, see above | `{ "type": "javascript", "javascript": "result = data.status === 'locked';" }` |
| `event` | a form event fires (`form.emit('<event>')`) | `{ "type": "event", "event": "lockEverything" }` |

## Action types

| Type | Effect |
| --- | --- |
| `property` | Sets a component property while the trigger is true — e.g. `disabled`, `hidden`, `required`, label text, CSS class. |
| `value` | Runs a JS snippet assigning `value` to set the component's value — user-supplied only, see above. |
| `mergeComponentSchema` | Merges a schema fragment into the component (change anything the JSON schema controls). |
| `customAction` | Runs an arbitrary JS snippet — user-supplied only, see above. |

## Complete example

Disable `notes` while `status` is `locked`:

```json
{
  "type": "textfield",
  "key": "notes",
  "label": "Notes",
  "input": true,
  "logic": [
    {
      "name": "lock notes while status is locked",
      "trigger": {
        "type": "json",
        "json": { "===": [{ "var": "data.status" }, "locked"] }
      },
      "actions": [
        {
          "name": "disable notes",
          "type": "property",
          "property": {
            "label": "Disabled",
            "value": "disabled",
            "type": "boolean"
          },
          "state": true
        }
      ]
    }
  ]
}
```

While `data.status === 'locked'` the component's `disabled` property is `true`; when the trigger stops matching, the property reverts.

A `mergeComponentSchema` variant of the same trigger:

```json
{
  "actions": [
    {
      "name": "make notes required",
      "type": "mergeComponentSchema",
      "schemaDefinition": "schema = { validate: { required: true } }"
    }
  ]
}
```

## See also

- [json-logic.md](./json-logic.md) — the `json` trigger's expression language.
- [conditionals.md](./conditionals.md) — visibility-only conditions.
- [javascript-api.md](./javascript-api.md) — `form.emit` for `event` triggers.
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall