{% with id=widget.attrs.id %}<fieldset{% if id %} id="{{ id }}"{% endif %}>{% for group, options, index in widget.optgroups %}{% if group %}
	<legend>{{ group }}</legend>{% endif %}{% for option in options %}
		{% include option.template_name with widget=option %}{% endfor %}{% if group %}
	{% endif %}{% endfor %}
</fieldset>{% endwith %}