{# The field controls, shared by the form dialog and the form page. #}
{% for field in fields %}
{% set flagged %}{% if field.error %}aria-invalid="true" aria-describedby="e-{{ field.name }}"{% endif %}{% endset %}
{% if field.kind in ("textarea", "json") %}
{# JSON arrives pretty-printed, so it needs the room to stay readable. #}
{% elif field.kind == "checkbox" %}
{% elif field.kind == "tristate" %}
{# A nullable boolean: the empty option is the null a checkbox cannot send. #}
{% elif field.kind == "relation" %}
{# A list of records rather than a key to memorise. #}
{% elif field.kind == "select" %}
{% else %}
{% set control_type = {"integer": "number", "number": "number", "datetime": "datetime-local", "date": "date"}.get(field.kind, "text") %}
{% endif %}
{% if field.error %}
{# Tied to the control by aria-describedby above, so it is announced, not merely seen. #}
{{ field.error }}
{% endif %}