Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
bb8690cf
Commit
bb8690cf
authored
Feb 20, 2015
by
José Padilla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable select field if no choices available
parent
dc8cc860
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
6 deletions
+21
-6
rest_framework/templates/rest_framework/horizontal/select_multiple.html
+7
-2
rest_framework/templates/rest_framework/inline/select_multiple.html
+7
-2
rest_framework/templates/rest_framework/vertical/select_multiple.html
+7
-2
No files found.
rest_framework/templates/rest_framework/horizontal/select_multiple.html
View file @
bb8690cf
{% 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 %}
...
...
rest_framework/templates/rest_framework/inline/select_multiple.html
View file @
bb8690cf
{% 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>
rest_framework/templates/rest_framework/vertical/select_multiple.html
View file @
bb8690cf
{% 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 %}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment