Skip to content

Commit

Permalink
Merge pull request encode#2587 from jpadilla/select-multiple-disabled
Browse files Browse the repository at this point in the history
Disable select field if no choices available
  • Loading branch information
tomchristie committed Feb 26, 2015
2 parents 03818ed + bb8690c commit 88cd86c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{% load i18n %}
{% trans "No items to select." as no_items %}

<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">
<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>
{% if field.errors %}
Expand Down
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>
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 {% if style.hide_label %}class="sr-only"{% endif %}>{{ 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>
{% if field.errors %}
Expand Down

0 comments on commit 88cd86c

Please sign in to comment.