[Fixed]-Data attribute for ChoiceField option

1👍

If you insist on rendering the field manually, then you also have to determine manually which item is selected, and output the selected attribute on the relevant one.

{% for choice in phone_code_field.field.extra_data %}
    <option {% if phone_code_field.field.value == choice.0.1 %}selected="selected"{% endif %} data-choice-code="{{ choice.0.0 }}" value="{{ choice.0.1 }}">{{ choice.1 }}</option>
{% endfor %}

Leave a comment