Built-in Schema Fields

CodeEditorField

Basic Usage

Use CodeEditorField when the schema needs HTML or plain-text source editing stored as a string in form state.

Registry

  • Key: codeEditor
  • Module: src/forms/fields/CodeEditorField.tsx

Role in SchemaForm

String-backed code editing using the CodeEditor component and FieldLayout, with useEngineField for store binding.

Host apps register the field automatically through the default SchemaForm registry. Formie maps PHP schema nodes with '$field' => 'codeEditor' to this component.

Common field props

PropTypeDefaultDescription
namestringForm value path.
labelstringField label.
instructionsstringHelp text below the label.
warningstringNon-blocking warning below errors.
placeholderstringForwarded to CodeMirror when supported.
language'html' | 'text' | 'javascript' | 'css' | 'json''html'Editor language mode.
rowsnumber12Minimum visible rows.
tabSizenumber4Tab width.
lineNumbersbooleantrueLine-number gutter visibility.
requiredbooleanfalseShows the required indicator.
disabledbooleanfalseDisables editing.

Example schema

json
{
  "$field": "codeEditor",
  "name": "htmlContent",
  "label": "HTML Content",
  "language": "html",
  "rows": 12,
  "tabSize": 4,
  "lineNumbers": true,
  "validation": "required"
}

Host configuration

Formie exposes project-config defaults through a PHP helper (HtmlHelper::getHtmlEditorConfig()), which merges into the schema node alongside standard field props. Other plugins can pass the same props directly on the schema field definition.

Typical defaults:

json
{
  "rows": 12,
  "tabSize": 4,
  "lineNumbers": true,
  "language": "html"
}