mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Merge pull request #2631 from Ins1ne/feature/issue-2559
Allow blank/null on radio.html choices
This commit is contained in:
commit
992971d648
|
@ -1,20 +1,37 @@
|
|||
{% load i18n %}
|
||||
{% trans "None" as none_choice %}
|
||||
|
||||
<div class="form-group">
|
||||
{% if field.label %}
|
||||
<label class="col-sm-2 control-label {% if style.hide_label %}sr-only{% endif %}">{{ field.label }}</label>
|
||||
{% endif %}
|
||||
<div class="col-sm-10">
|
||||
{% if style.inline %}
|
||||
{% if field.allow_null or field.allow_blank %}
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="{{ field.name }}" value="" {% if not field.value %}checked{% endif %} />
|
||||
{{ none_choice }}
|
||||
</label>
|
||||
{% endif %}
|
||||
{% for key, text in field.choices.items %}
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="{{ field.name }}" value="{{ key }}" {% if key == field.value %}checked{% endif %}>
|
||||
<input type="radio" name="{{ field.name }}" value="{{ key }}" {% if key == field.value %}checked{% endif %} />
|
||||
{{ text }}
|
||||
</label>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% if field.allow_null or field.allow_blank %}
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="{{ field.name }}" value="" {% if not field.value %}checked{% endif %} />
|
||||
{{ none_choice }}
|
||||
</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% for key, text in field.choices.items %}
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="{{ field.name }}" value="{{ key }}" {% if key == field.value %}checked{% endif %}>
|
||||
<input type="radio" name="{{ field.name }}" value="{{ key }}" {% if key == field.value %}checked{% endif %} />
|
||||
{{ text }}
|
||||
</label>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,18 @@
|
|||
{% load i18n %}
|
||||
{% trans "None" as none_choice %}
|
||||
|
||||
<div class="form-group {% if field.errors %}has-error{% endif %}">
|
||||
{% if field.label %}
|
||||
<label class="sr-only">{{ field.label }}</label>
|
||||
{% endif %}
|
||||
{% if field.allow_null or field.allow_blank %}
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="{{ field.name }}" value="" {% if not field.value %}checked{% endif %}>
|
||||
{{ none_choice }}
|
||||
</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% for key, text in field.choices.items %}
|
||||
<div class="radio">
|
||||
<label>
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
{% load i18n %}
|
||||
{% trans "None" as none_choice %}
|
||||
|
||||
<div class="form-group {% if field.errors %}has-error{% endif %}">
|
||||
{% if field.label %}
|
||||
<label {% if style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
|
||||
{% endif %}
|
||||
{% if style.inline %}
|
||||
<div>
|
||||
{% if field.allow_null or field.allow_blank %}
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="{{ field.name }}" value="" {% if not field.value %}checked{% endif %} />
|
||||
{{ none_choice }}
|
||||
</label>
|
||||
{% endif %}
|
||||
{% for key, text in field.choices.items %}
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="{{ field.name }}" value="{{ key }}" {% if key == field.value %}checked{% endif %}>
|
||||
|
@ -12,6 +21,14 @@
|
|||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% if field.allow_null or field.allow_blank %}
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="{{ field.name }}" value="" {% if not field.value %}checked{% endif %} />
|
||||
{{ none_choice }}
|
||||
</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% for key, text in field.choices.items %}
|
||||
<div class="radio">
|
||||
<label>
|
||||
|
|
Loading…
Reference in New Issue
Block a user