{% comment %} Segmented Control (choices) =========================== Generic N-segment sibling of segmented_control.html: one segment per choice of a ChoiceField/TypedChoiceField instead of the fixed remote/local pair. The slider is pure CSS (`:has()` + nth-of-type), sized off --fw-seg-count; styles cover up to five segments. Sized to the shared MD3 field height (56dp) so it can sit in a form row next to outlined fields. Label/help/ errors follow the MD3 standard (group label + supporting text). Required context: - field: bound ChoiceField/TypedChoiceField (its choices become the segments) Optional context: - hx_get/hx_target/hx_swap/hx_trigger/hx_include/hx_indicator: forwarded to every radio, exactly like segmented_control.html. The triggering radio submits its own name/value, so no hx-vals is needed. - locked: render disabled - show_label/show_help_text, label, help_text, show_required, required: same as the other MD3 widgets (pass label="" to render no label at all) {% endcomment %} {% with choices=field.field.choices %}
{% if show_label != False and label|default:field.label %} {{ label|default:field.label }}{% if show_required != False and required|default:field.field.required %} *{% endif %} {% endif %}
{% for value, choice_label in choices %} {% endfor %}
{% if field.errors %}
{% for error in field.errors %}{{ error }}{% endfor %}
{% elif show_help_text != False and help_text|default:field.help_text %}
{{ help_text|default:field.help_text }}
{% endif %}
{% endwith %}