Add --- null option for selects. Closes #2096.

This commit is contained in:
Tom Christie 2014-11-20 12:38:08 +00:00
parent 6794b3380a
commit 9c6bead8b6
3 changed files with 11 additions and 2 deletions

View File

@ -4,6 +4,9 @@
{% endif %} {% endif %}
<div class="col-sm-10"> <div class="col-sm-10">
<select class="form-control" name="{{ field.name }}"> <select class="form-control" name="{{ field.name }}">
{% if field.allow_null %}
<option value="" {% if not field.value %}selected{% endif %}>--------</option>
{% endif %}
{% for key, text in field.choices.items %} {% for key, text in field.choices.items %}
<option value="{{ key }}" {% if key == field.value %}selected{% endif %}>{{ text }}</option> <option value="{{ key }}" {% if key == field.value %}selected{% endif %}>{{ text }}</option>
{% endfor %} {% endfor %}

View File

@ -3,8 +3,11 @@
<label class="sr-only">{{ field.label }}</label> <label class="sr-only">{{ field.label }}</label>
{% endif %} {% endif %}
<select class="form-control" name="{{ field.name }}"> <select class="form-control" name="{{ field.name }}">
{% if field.allow_null %}
<option value="" {% if not field.value %}selected{% endif %}>--------</option>
{% endif %}
{% for key, text in field.choices.items %} {% for key, text in field.choices.items %}
<option value="{{ key }}" {% if key == field.value %}selected{% endif %}>{{ text }}</option> <option value="{{ key }}" {% if key == field.value %}selected{% endif %}>{{ text }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>

View File

@ -3,8 +3,11 @@
<label {% if style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label> <label {% if style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
{% endif %} {% endif %}
<select class="form-control" name="{{ field.name }}"> <select class="form-control" name="{{ field.name }}">
{% if field.allow_null %}
<option value="" {% if not field.value %}selected{% endif %}>--------</option>
{% endif %}
{% for key, text in field.choices.items %} {% for key, text in field.choices.items %}
<option value="{{ key }}" {% if key == field.value %}selected{% endif %}>{{ text }}</option> <option value="{{ key }}" {% if key == field.value %}selected{% endif %}>{{ text }}</option>
{% endfor %} {% endfor %}
</select> </select>
{% if field.errors %} {% if field.errors %}