Skip to main content

Module form

Module form 

Source
Expand description

Admin-new form engine.

Turn a FormConfig of FieldConfigs into drawer-based form HTML. Every input type routes through a dedicated renderer that uses only classnames present in the approved components.css — no new classes, no new styles, no JS, no filesystem, no DB.

The ForeignKey rule is load-bearing: FK fields always render as a <select> populated from FieldConfig::options. Raw numeric row ids are never presented to the admin user; the caller resolves (value, label) pairs upstream and passes human-readable labels in.

UI-level validation lives here too: validate_form walks the fields, applies a small set of basic rules (required / email / number), and writes any failure into FieldConfig::error. The renderers add class="invalid" to the input and append a .field-error block below — both classes are referenced but not styled here; styling is assumed to live in the bundled CSS.

Structs§

FieldConfig
FormConfig

Enums§

FieldType

Functions§

bind_form
Pull submitted values out of a parsed urlencoded body and write them into the form’s fields.
infer_field_type
Infer a likely FieldType from a field name.
render_error
Render the .field-error block for a single message. Empty msg → empty string, so callers don’t need to gate the call.
render_field
render_form
validate_form
Walk the form’s fields and apply the basic validation rules: