{% load l10n fontawesome_5 %}
{% for code in codes %}
<div class="ml-4 tree-element">
    <label class="tree-label collapsed" role="{% if not code.is_leaf%}button{% endif %}" for="input_{{code.pk|unlocalize}}" id="{{code.pk|unlocalize}}" data-toggle="collapse" data-target="#children_{{code.pk|unlocalize}}" aria-expanded="true" aria-controls="children_{{code.pk|unlocalize}}">
        {% if code.is_leaf%}
        <input class="tree-input" id="input_{{code.pk|unlocalize}}" name="{{ widget.name }}" type="radio" value="{{code.pk|unlocalize}}" {% if code.pk|unlocalize in widget.value %}checked{% endif %}/>
        {% else %}
        <span class="collapse-icn">
            {% fa5_icon 'angle-down' %}
        </span>
        {% endif %}
        {% if code.short_name %}
            ({{code.short_name}})
        {% endif %}
        {{code.long_name}}
    </label>
    {% if not code.is_leaf %}
    <div id="children_{{code.pk|unlocalize}}" data-toggle="collapse" class="collapse tree-element-children">
        {% with code.children as codes %}
        {% include 'konova/widgets/tree/radio/radio-tree-select-content.html' %}
        {% endwith %}
    </div>
    {% endif %}
</div>
{% endfor %}