Skip to content
docsv0.9.0

SchemaFormHtmlRenderer

Renders a FormView to the styled milpa/live form-widget HTML fragment — FIELDS ONLY, never the `<form>` wrapper (that is transport-specific host glue owned by a later task). Each FieldType maps to a milpa/live form component (Boolean -> checkbox, an `enumOptions` constraint -> select, else -> text/number input); current values and per-field error messages ride as tag attributes into the real {@see FormPrimitiveHtmlRenderer}/{@see XhtmlComponentCompiler} pipeline, so the emitted markup carries the same Alpine directives — and the same no-JS degradation story — as any other milpa/live form widget (ADR#6, progressive enhancement).

SchemaFormHtmlRenderer::__construct()

public function __construct(?callable $messageResolver = null):

The resolver turns a field's first validation error into the message the user reads. It gets the `FieldError` — switch on its stable `code`, a closed set — and the `FormField`, for its `label`. Left null it returns the error's own English `message`, which is the prior behavior and keeps this constructor backward compatible. A host in another language injects one keyed on `code`, so the UI never pairs a translated label with an English suffix ("Nombre del sitio is required.").

Parameters

Parameters of __construct()
NameTypeDescription
$messageResolver?callable(FieldError, FormField): string

SchemaFormHtmlRenderer::render()

public function render(Milpa\Live\Schema\FormView $view): string

Renders one `<milpa:*>` fragment tag per field in `$view->definition`, compiled through the real form-primitive rendering pipeline, with current values and first-error messages injected.

Parameters

Parameters of render()
NameTypeDescription
$viewMilpa\Live\Schema\FormView