Skip to content

Commit 7159b31

Browse files
committed
update vertical and inline layouts for radio choices
1 parent fdd811e commit 7159b31

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

rest_framework/templates/rest_framework/horizontal/radio.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% load i18n %}
2+
{% trans "None" as none_choice %}
23

34
<div class="form-group">
45
{% if field.label %}
@@ -9,7 +10,7 @@
910
{% if field.allow_null or field.allow_blank %}
1011
<label class="radio-inline">
1112
<input type="radio" name="{{ field.name }}" value="" {% if not field.value %}checked{% endif %} />
12-
{% trans "None" %}
13+
{{ none_choice }}
1314
</label>
1415
{% endif %}
1516
{% for key, text in field.choices.items %}
@@ -23,7 +24,7 @@
2324
<div class="radio">
2425
<label>
2526
<input type="radio" name="{{ field.name }}" value="" {% if not field.value %}checked{% endif %} />
26-
{% trans "None" %}
27+
{{ none_choice }}
2728
</label>
2829
</div>
2930
{% endif %}

rest_framework/templates/rest_framework/inline/radio.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
{% load i18n %}
2+
{% trans "None" as none_choice %}
3+
14
<div class="form-group {% if field.errors %}has-error{% endif %}">
25
{% if field.label %}
36
<label class="sr-only">{{ field.label }}</label>
47
{% endif %}
8+
{% if field.allow_null or field.allow_blank %}
9+
<div class="radio">
10+
<label>
11+
<input type="radio" name="{{ field.name }}" value="" {% if not field.value %}checked{% endif %}>
12+
{{ none_choice }}
13+
</label>
14+
</div>
15+
{% endif %}
516
{% for key, text in field.choices.items %}
617
<div class="radio">
718
<label>

rest_framework/templates/rest_framework/vertical/radio.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
{% load i18n %}
2+
{% trans "None" as none_choice %}
3+
14
<div class="form-group {% if field.errors %}has-error{% endif %}">
25
{% if field.label %}
36
<label {% if style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
47
{% endif %}
58
{% if style.inline %}
69
<div>
10+
{% if field.allow_null or field.allow_blank %}
11+
<label class="radio-inline">
12+
<input type="radio" name="{{ field.name }}" value="" {% if not field.value %}checked{% endif %} />
13+
{{ none_choice }}
14+
</label>
15+
{% endif %}
716
{% for key, text in field.choices.items %}
817
<label class="radio-inline">
918
<input type="radio" name="{{ field.name }}" value="{{ key }}" {% if key == field.value %}checked{% endif %}>
@@ -12,6 +21,14 @@
1221
{% endfor %}
1322
</div>
1423
{% else %}
24+
{% if field.allow_null or field.allow_blank %}
25+
<div class="radio">
26+
<label>
27+
<input type="radio" name="{{ field.name }}" value="" {% if not field.value %}checked{% endif %} />
28+
{{ none_choice }}
29+
</label>
30+
</div>
31+
{% endif %}
1532
{% for key, text in field.choices.items %}
1633
<div class="radio">
1734
<label>

0 commit comments

Comments
 (0)