{% props field: Field, legend: String, options: Vec<(String, String, String)>, r#type: String = "radio", columns: String = "" %}
{#- options: (value, label, hint); hint may be "". r#type "checkbox" takes several values, the field's value comma-separated. #}
<fieldset class="ui-choice-group"{% if !columns.is_empty() %} data-columns="{{ columns }}"{% end %}{% if field.has_errors() %} aria-describedby="{{ field.id }}-error"{% end %}>
<legend class="ui-legend">{{ legend }}</legend>
{%- if field.has_errors() %}
<p class="ui-field-error" id="{{ field.id }}-error">{%- for message in field.errors.iter() %}{{ field.label }} {{ message }}. {% end %}</p>
{%- end %}
{%- for (value, label, hint) in options.iter() %}
{%- let checked = if r#type == "checkbox" { field.value.split(',').any(|v| v.trim() == value) } else { field.value == *value } %}
<label class="ui-choice"><input class="{% if r#type == "checkbox" %}ui-checkbox{% else %}ui-radio{% end %}" type="{{ r#type }}" name="{{ field.name }}" value="{{ value }}"{% if checked %} checked{% end %}{% if field.has_errors() %} aria-invalid="true"{% end %}><span class="ui-choice-text"><span class="ui-choice-label">{{ label }}</span>{% if !hint.is_empty() %}<span class="ui-choice-hint">{{ hint }}</span>{% end %}</span></label>
{%- end %}
</fieldset>