journeys / journey-xml-5Markdown ↓

Forms and validation

Choose form when you know the fields at authoring time. Each field requires key, label and kind. Labels help people; keys are the stable state contract. required, placeholder, help, defaultValue and resourceType are optional attributes, with resourceType required by resourcePicker.

<journey id="fields" title="Typed details">
  <form id="details" title="Details">
    <field key="slug" label="Slug" kind="text" required="true" help="Lowercase letters and hyphens">
      <validation pattern="^[a-z-]+$"/>
    </field>
    <field key="notes" label="Notes" kind="multiline" placeholder="Optional context"/>
    <field key="copies" label="Copies" kind="number" required="true" defaultValue="1">
      <validation min="1" max="100"/>
    </field>
    <field key="urgent" label="Urgent" kind="toggle" defaultValue="false"/>
    <field key="due" label="Due date" kind="date">
      <when><eq path="$.state.urgent" type="boolean" value="true"/></when>
    </field>
    <field key="mode" label="Mode" kind="choice" required="true" defaultValue="standard">
      <option value="standard" label="Standard" detail="Normal processing"/>
      <option value="express" label="Express"/>
    </field>
    <field key="customer" label="Customer" kind="resourcePicker" resourceType="customer"/>
  </form>
  <done id="done" title="Ready"><body>{{ $.state.slug }}: {{ $.state.copies }} copies.</body></done>
</journey>
Kind State value
text, multiline String
number Number
toggle Boolean
date ISO date string
choice Selected option value string
resourcePicker Object containing id and label

Defaults are XML strings coerced by the engine to the field type on first entry when the key has no value. A choice default must be one of its option values, and a date default is an ISO date such as 2026-09-29. Returning to a stage retains existing answers. A toggle default of false is a boolean, not the text "false". A required toggle requires a value, not necessarily true; use an explicit condition or validation design when affirmative consent is needed.

A validation child supports pattern for text and multiline, and min/max for numbers. Visible required fields and visible validation errors block Next. A field's when condition controls visibility reactively. Hiding a field does not promise to erase its old value: guard downstream use as well.

A choice contains option children with value and label, plus optional detail. A resourcePicker uses the CoCoCo app's resource lookup. Available resource types depend on your instance; for arbitrary API-backed choices use query-pick. These examples do not assert every resource is available in every deployment.

Published platform manual · revision 12dbe6e5b884