Concepts

Field conditions

Field conditions let a collection field change visibility, readonly, or required based on other field values on the same item. Form UX (client) and server enforcement for required / readonly stay in sync.

Sources of truth

PHP: App\Services\Collections\FieldConditionEvaluator. TS: resources/js/lib/field-conditions.ts. Settings UI: field settings → Conditions. Stored under collections_fields.settings.conditions.

Shape

{
  "logic": "and",
  "rules": [{ "field": "status", "operator": "equals", "value": "published" }],
  "hidden": false,
  "readonly": true,
  "required": true
}
KeyMeaning
logicand (default) — all rules must match; or — any rule matches
rulesFlat list of { field, operator, value? } (no nested groups)
hiddenWhen matched: hide field. Explicit false = show-when (hide unless matched)
readonlyWhen matched: lock field (server strips writes)
requiredWhen matched: require a value (server validation)

Existing AND / equals rules keep working unchanged.

Operators

OperatorValueMatch when…
equalsanyLoose string equality (arrays: contains expected); booleans tolerate 0/1
not_equalsanyNegation of equals
containsstring / numberString substring, or array membership
empty—null, blank string, or []
not_empty—Negation of empty
gt / gte / lt / ltenumber or ISO date prefixNumeric compare, or lexicographic ISO YYYY-MM-DD…
incomma list or arrayActual (or any array element) is in the list
not_incomma list or arrayNegation of in

Examples

Show notes only when kind is custom (show-when):

{
  "logic": "and",
  "rules": [{ "field": "kind", "operator": "equals", "value": "custom" }],
  "hidden": false
}

Require price when status is draft or review (OR + in):

{
  "logic": "or",
  "rules": [
    { "field": "status", "operator": "equals", "value": "draft" },
    { "field": "status", "operator": "in", "value": "review, pending" }
  ],
  "required": true
}

Lock title after publish date is set (gte):

{
  "logic": "and",
  "rules": [
    { "field": "published_at", "operator": "gte", "value": "2020-01-01" }
  ],
  "readonly": true
}

Kitchen Sink sketch

On a demo collection with kind (select), status (select), amount (number), notes (string):

  1. Hide notes unless kind equals custom.
  2. Require amount when status is in draft, review or amount gt 0 is not enough alone — prefer one rule set per effect.
  3. Readonly status when published_at is not_empty.

Out of scope

No Flow builder, no HTTP / external conditions, no nested rule groups. Extend via Extending if you need that.

Previous
Field types