1# llimphi-widget-form
2
3Form validation on top of `llimphi-widget-field`.
4
5A form validates in three stages, and the one usually done wrong is the third:
6
71. **what is asked** — per-field rules (`Regla`, `CampoDef`);
82. **what is wrong** — aggregation (`Formulario::validar` → `Errores`), which
9 collects **every** problem, not just the first;
103. **when it is said** — `EstadoForm`. A form that shouts "required" at an empty
11 field you have not touched yet is hostile, and one that hides the error until
12 submit makes you go back and forth. The rule: show on **blur** (`tocar`) or
13 on **submit attempt** (`enviar`), never while typing for the first time.
14
15Pure logic plus two glue views. Values still live in the caller's `Model`: there
16is no `Form` holding buffers here, because that would mean keeping two sources
17of truth in sync.
18
19`campo_view` pulls the label, the required asterisk and the error out of the
20form definition, so those three stop being written twice — which is how they end
21up disagreeing. `resumen_errores_view` builds the navigable summary for the
22header: in a long form the error may be off-screen, and all you see is that the
23button did nothing.
24
25---
26
27Part of **llimphi** — see [llimphi](../../README.md).
README.md
llimphi-widget-form
Form validation on top of llimphi-widget-field.
A form validates in three stages, and the one usually done wrong is the third:
- what is asked — per-field rules (
Regla, CampoDef);
- what is wrong — aggregation (
Formulario::validar → Errores), which
collects every problem, not just the first;
- when it is said —
EstadoForm. A form that shouts "required" at an empty
field you have not touched yet is hostile, and one that hides the error until
submit makes you go back and forth. The rule: show on blur (tocar) or
on submit attempt (enviar), never while typing for the first time.
Pure logic plus two glue views. Values still live in the caller's Model: there
is no Form holding buffers here, because that would mean keeping two sources
of truth in sync.
campo_view pulls the label, the required asterisk and the error out of the
form definition, so those three stop being written twice — which is how they end
up disagreeing. resumen_errores_view builds the navigable summary for the
header: in a long form the error may be off-screen, and all you see is that the
button did nothing.
Part of llimphi — see llimphi.