Skip to content

API Reference parrot_formdesigner.controls.registry

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_formdesigner.controls.registry

View source

Form-control registry.

Extending the toolbar:

from parrot_formdesigner.controls import register_field_control

register_field_control(
    "rich_text",
    label="Rich Text",
    description="Rich text editor",
    category="advanced",
    icon="rich-text",
    snippet={"type": "string", "format": "rich-text"},
    render_hint="rich",
    supports_constraints=True,
)

Call this once at consumer startup, before setup_form_api(app, registry) is called (or any time before the first request — the seed and extensions live in the same module-level dict).

Class FieldControlMetadata

Metadata describing a single form-control entry for the toolbar.

Fields:

Field Type Default Description
type str Canonical id (FieldType.value or extension type id).
label str Short, human-readable name.
description str Description shown in the toolbar tooltip / help.
category str Grouping bucket — one of "basic" | "selection" | "media" | "layout" | "advanced".
icon str Consumer-defined glyph name.
snippet dict[str, Any] JSON Schema snippet seed to drop into a new form.
render_hint str UI hint such as "input" | "select" | "container".
supports_constraints bool Whether the control supports validation constraints (min/max length, regex, etc.).
is_container bool False Whether the control nests other fields (groups, arrays).
supported_operators list[str] [] List of ConditionOperator values meaningful for this control type (used in depends_on.conditions and post_depends.conditions). Empty list = all operators accepted. Optional — omit for extension types.
supported_effects list[str] [] List of pre-dependency effect values applicable to this control ("show" | "hide" | "require" | "disable"). Empty list = all effects applicable. Optional.
supported_operations list[str] [] List of :class:DependencyOperation op values that make semantic sense for this control type (e.g. arithmetic ops only for numeric types). Empty list = all ops applicable. Optional.
value_shape dict[str, Any] {} The type-only JSON Schema value-shape contract (FEAT-448 TASK-2338) — e.g. {"type": "string", "format": "signature"} or {"type": "object", "properties": {...}, "required": [...]}. For FieldType entries this is sourced from renderers.jsonschema.type_level_value_shape() so the catalog and the JSON Schema renderer can never drift apart — the whole point of publishing this contract at all (spec §5.5). Optional — defaults to {} for extension types that don't provide one.

Alias FieldType

Re-exported from parrot_formdesigner.core.types.FieldType.

Function get_controls

Return all registered controls in registration order.

get_controls() -> list[FieldControlMetadata]

Returns: list[FieldControlMetadata] — A list of FieldControlMetadata instances in the order they were registered. The list is a fresh copy of the registry's values.

Function iter_controls

Yield registered controls in registration order.

iter_controls() -> Iterator[FieldControlMetadata]

Returns: Iterator[FieldControlMetadata]

Attribute logger

Function register_field_control

Register (or overwrite) a control entry in the toolbar registry.

Idempotent: re-registering the same field_type overwrites the previous entry and logs a warning.

register_field_control(field_type: FieldType | str, *, label: str, description: str, category: str, icon: str, snippet: dict[str, Any], render_hint: str, supports_constraints: bool, is_container: bool = False, supported_operators: list[str] | None = None, supported_effects: list[str] | None = None, supported_operations: list[str] | None = None, value_shape: dict[str, Any] | None = None) -> None

Parameter Type Default Description
field_type FieldType | str A FieldType enum or a string id (for extension types).
label str Short, human-readable label.
description str Description for the toolbar tooltip / help.
category str One of "basic" | "selection" | "media" | "layout" | "advanced".
icon str Consumer-defined glyph name.
snippet dict[str, Any] JSON Schema snippet seed.
render_hint str UI hint (e.g. "input", "select", "container").
supports_constraints bool Whether the control supports validation constraints.
is_container bool False Whether the control nests other fields. Defaults to False.
supported_operators list[str] | None None ConditionOperator values meaningful for this type. None (default) and [] both mean "all operators applicable".
supported_effects list[str] | None None Dependency effect values applicable to this type. None (default) and [] both mean "all effects applicable".
supported_operations list[str] | None None DependencyOperation.op values that make sense for this type. None (default) and [] both mean "all ops".
value_shape dict[str, Any] | None None The type-only JSON Schema value-shape contract (FEAT-448 TASK-2338). None (default) means {} — no contract published.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally