Skip to main content

Module form

Module form 

Source
Expand description

Descriptor-driven create and edit forms.

A FormConfig describes a table and its editable fields. Generic handlers render an empty form (new), a populated form (edit), and persist through a crate::persist::Persister: the descriptor-driven default (a parameterized insert/update over the form’s columns), or a named handler for a custom write. A submission is checked by the framework validation engine (laterite_core::validation); a failure re-renders the form with per-field messages instead of writing.

Field types resolve through the registry (crate::field); text, textarea, select, and reference ship built-in. Fields needing a typed stored value (a switch over a bool column, password hashing) arrive with the typed-save contract.

The primary key is a bigint auto-increment column the database assigns, so create inserts only the descriptor’s fields and never sets the id. An entity with other required columns that lack defaults (for example audit timestamps) is beyond this slice; those are filled by a later timestamp-aware widget.

Structs§

FormConfig
A form descriptor: which table, its editable fields, the id column, and the base path the form lives under ({base_path}/new, {base_path}/{id}/edit).
FormField
One editable field: the column, its label, its field-type key (resolved through the field-type registry), typed options for that type, the validation rules it carries, and whether it holds translatable content. A serde descriptor, so it is authorable as data (later YAML) as well as by builder.
Preset
Fills a field from another as it is typed, until the field is edited.
Span
The share of a row a field takes, in twelfths. Written in YAML as a fraction (1/2, 1/3, 2/3, 1/4, 3/4), full, a count of columns (1 to 12), or the words half, third, quarter, left, right and auto (each a half). Fields flow left to right and wrap when a row is full.
Trigger
Changes a field when another field’s state meets a condition.

Enums§

EnterPolicy
What Enter does in a form’s single-line fields.
FieldEnter
What Enter does in one field, over the form’s EnterPolicy.
FormFocus
Where the cursor goes when a form opens.
PresetShape
How a preset shapes the text it copies.