mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 00:04:16 +03:00
Add --- null option for selects. Closes #2096.
This commit is contained in:
parent
6794b3380a
commit
9c6bead8b6
|
@ -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 %}
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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 %}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user