I've to modify the radio_widget
and would like to give the <label>
and <input>
the same ID, which should be unique for each pair.
Currently I'm using random(), but I'd prefer an internal counter, something like {{loop.index}}
(Twig: for), to avoid conflicts.
{% block radio_widget -%}
{% set id = random() %}
<div class="radio">
<label for="radio_{{ id }}">Label for {{ id }}</label>
<input type="radio" id="radio_{{ id }}" {# ...#}/>
</div>
{%- endblock radio_widget %}
Does anyone know a better solution?
Thanks in advance!