From bb8690cfb3208440c35a5c35eb65562f7e1729cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Padilla?= Date: Fri, 20 Feb 2015 11:43:12 -0400 Subject: [PATCH] Disable select field if no choices available --- .../rest_framework/horizontal/select_multiple.html | 9 +++++++-- .../templates/rest_framework/inline/select_multiple.html | 9 +++++++-- .../rest_framework/vertical/select_multiple.html | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/rest_framework/templates/rest_framework/horizontal/select_multiple.html b/rest_framework/templates/rest_framework/horizontal/select_multiple.html index 01c251fb0..0735f2809 100644 --- a/rest_framework/templates/rest_framework/horizontal/select_multiple.html +++ b/rest_framework/templates/rest_framework/horizontal/select_multiple.html @@ -1,11 +1,16 @@ +{% load i18n %} +{% trans "No items to select." as no_items %} +
{% if field.label %} {% endif %}
- {% for key, text in field.choices.items %} - + + {% empty %} + {% endfor %} {% if field.errors %} diff --git a/rest_framework/templates/rest_framework/inline/select_multiple.html b/rest_framework/templates/rest_framework/inline/select_multiple.html index feddf7abd..5a8b2494b 100644 --- a/rest_framework/templates/rest_framework/inline/select_multiple.html +++ b/rest_framework/templates/rest_framework/inline/select_multiple.html @@ -1,10 +1,15 @@ +{% load i18n %} +{% trans "No items to select." as no_items %} +
{% if field.label %} {% endif %} - {% for key, text in field.choices.items %} - + + {% empty %} + {% endfor %}
diff --git a/rest_framework/templates/rest_framework/vertical/select_multiple.html b/rest_framework/templates/rest_framework/vertical/select_multiple.html index 54839294a..81b25c2a3 100644 --- a/rest_framework/templates/rest_framework/vertical/select_multiple.html +++ b/rest_framework/templates/rest_framework/vertical/select_multiple.html @@ -1,10 +1,15 @@ +{% load i18n %} +{% trans "No items to select." as no_items %} +
{% if field.label %} {% endif %} - {% for key, text in field.choices.items %} - + + {% empty %} + {% endfor %} {% if field.errors %}