1π
β
I donβt know why it works like that. My guess would be that those idβs are created by an iterator created by the forms api. A single country is not aware of the iterator (it could appear in the template without appearing within a for loop), therefor thereβs no way of creating the id.
To answer your other question β Yes you could build the inputs yourself to include the idβs.
something like β
{% for country in form.country %}
<li>
<img src="{{ MEDIA_URL }}country_icons/country_{{ country.value }}.png">
<label for="id_country_{{ forloop.counter0 }}">
<input id="id_country_{{ forloop.counter0 }}" type="radio" value="{{ country.value }}" name={{ country }}>
</label>
{{ country.name }}
</li>
{% endfor %}
Have a look at the docs on template for loops
π€Aidan Ewen
Source:stackexchange.com