forked from encode/django-rest-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request encode#2587 from jpadilla/select-multiple-disabled
Disable select field if no choices available
- Loading branch information
Showing
3 changed files
with
21 additions
and
6 deletions.
There are no files selected for viewing
9 changes: 7 additions & 2 deletions
9
rest_framework/templates/rest_framework/horizontal/select_multiple.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletions
9
rest_framework/templates/rest_framework/inline/select_multiple.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
{% load i18n %} | ||
{% trans "No items to select." as no_items %} | ||
|
||
<div class="form-group {% if field.errors %}has-error{% endif %}"> | ||
{% if field.label %} | ||
<label class="sr-only">{{ field.label }}</label> | ||
{% endif %} | ||
<select multiple class="form-control" name="{{ field.name }}"> | ||
<select multiple {{ field.choices|yesno:",disabled" }} class="form-control" name="{{ field.name }}"> | ||
{% for key, text in field.choices.items %} | ||
<option value="{{ key }}" {% if key in field.value %}selected{% endif %}>{{ text }}</option> | ||
<option value="{{ key }}" {% if key in field.value %}selected{% endif %}>{{ text }}</option> | ||
{% empty %} | ||
<option>{{ no_items }}</option> | ||
{% endfor %} | ||
</select> | ||
</div> |
9 changes: 7 additions & 2 deletions
9
rest_framework/templates/rest_framework/vertical/select_multiple.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters