Skip to content

Instantly share code, notes, and snippets.

@lgvital
Created March 28, 2014 22:43
Show Gist options
  • Save lgvital/9844519 to your computer and use it in GitHub Desktop.
Save lgvital/9844519 to your computer and use it in GitHub Desktop.
diff --git a/template/tenxer/shared/macros/forms.html b/template/tenxer/shared/macros/forms.html
index 5e68dfb..5450da4 100644
--- a/template/tenxer/shared/macros/forms.html
+++ b/template/tenxer/shared/macros/forms.html
@@ -201,14 +201,16 @@
{{ option(field, attrs=attr, label=group.1) }}
{% else %}
<optgroup label="{{ group.0 }}">
- {% for choice in group.1 %}
- {% if (fvalue|string == choice.0|string) or (fvalue is iterable and choice.0|string in fvalue|map('string')) %}
- {% set attr = {"selected":"selected","value": choice.0} %}
- {% else %}
- {% set attr = {"value": choice.0} %}
- {% endif %}
- {{ option(field, attrs=attr, label=choice.1) }}
- {% endfor %}
+ {% if group.1 %}
+ {% for choice in group.1 %}
+ {% if (fvalue|string == choice.0|string) or (fvalue is iterable and choice.0|string in fvalue|map('string')) %}
+ {% set attr = {"selected":"selected","value": choice.0} %}
+ {% else %}
+ {% set attr = {"value": choice.0} %}
+ {% endif %}
+ {{ option(field, attrs=attr, label=choice.1) }}
+ {% endfor %}
+ {% endif %}
</optgroup>
{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment