Skip to content
Corex

FieldRenderer

Corex\Forms\Block\FieldRenderer · class · Forms layer

Renders one form field to accessible, token-only, escaped HTML — the whole field (wrapper + label/legend + control + error region), because label semantics depend on the control type (a single input uses <label for>; a radio/checkbox group uses <fieldset><legend>). Supports every input type the form builder exposes plus the per-field presentation knobs (label mode, column width, custom class + attributes). Pure of business logic; FormBlockRenderer composes these into the form.

render(string $slug, FieldSchema $field): string

Section titled “render(string $slug, FieldSchema $field): string”

id(string $slug, FieldSchema $field): string

Section titled “id(string $slug, FieldSchema $field): string”

The id a field’s control carries. Its label, its help text and its error place are all tied to it.

errorPlace(string $slug, FieldSchema $field): string

Section titled “errorPlace(string $slug, FieldSchema $field): string”

Where the runtime writes a field’s error. It is announced when it is written.

labelFor(string $slug, FieldSchema $field): string

Section titled “labelFor(string $slug, FieldSchema $field): string”

A field’s label, tied to its control.

controlAttributes(string $slug, FieldSchema $field): array

Section titled “controlAttributes(string $slug, FieldSchema $field): array”

What a control written by hand has to carry to be this field’s: its id and name, the places that describe it, and that it is required.