diff options
| author | Aider Ibragimov | 2015-03-04 08:22:46 +0300 |
|---|---|---|
| committer | Aider Ibragimov | 2015-03-04 08:22:46 +0300 |
| commit | fdd811ec53b3bdc46a2c934422066e1aa9f9dd05 (patch) | |
| tree | 329cb895ca5b673dc6fd890be8f9b01223977ad1 /rest_framework | |
| parent | 932998134fa15ca955d2575349078b2de8ddf892 (diff) | |
| download | django-rest-framework-fdd811ec53b3bdc46a2c934422066e1aa9f9dd05.tar.bz2 | |
Allow blank/null on radio.html choices
Diffstat (limited to 'rest_framework')
| -rw-r--r-- | rest_framework/templates/rest_framework/horizontal/radio.html | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/rest_framework/templates/rest_framework/horizontal/radio.html b/rest_framework/templates/rest_framework/horizontal/radio.html index 52238bb1..efca2883 100644 --- a/rest_framework/templates/rest_framework/horizontal/radio.html +++ b/rest_framework/templates/rest_framework/horizontal/radio.html @@ -1,20 +1,36 @@ +{% load i18n %} + <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 %} /> + {% trans "None" %} + </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 %} /> + {% trans "None" %} + </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> |
