Skip to content

Commit b7ed645

Browse files
Ryan P Kilbycarltongibson
authored andcommitted
Disable HTML inputs for dict/list fields (#5702)
1 parent 6bd773e commit b7ed645

File tree

7 files changed

+60
-0
lines changed

7 files changed

+60
-0
lines changed

rest_framework/renderers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ class HTMLFormRenderer(BaseRenderer):
320320
serializers.ListSerializer: {
321321
'base_template': 'list_fieldset.html'
322322
},
323+
serializers.ListField: {
324+
'base_template': 'list_field.html'
325+
},
326+
serializers.DictField: {
327+
'base_template': 'dict_field.html'
328+
},
323329
serializers.FilePathField: {
324330
'base_template': 'select.html',
325331
},
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div class="form-group">
2+
{% if field.label %}
3+
<label class="col-sm-2 control-label {% if style.hide_label %}sr-only{% endif %}">
4+
{{ field.label }}
5+
</label>
6+
{% endif %}
7+
8+
<div class="col-sm-10">
9+
<p class="form-control-static">Dictionaries are not currently supported in HTML input.</p>
10+
</div>
11+
</div>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div class="form-group">
2+
{% if field.label %}
3+
<label class="col-sm-2 control-label {% if style.hide_label %}sr-only{% endif %}">
4+
{{ field.label }}
5+
</label>
6+
{% endif %}
7+
8+
<div class="col-sm-10">
9+
<p class="form-control-static">Lists are not currently supported in HTML input.</p>
10+
</div>
11+
</div>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div class="form-group">
2+
{% if field.label %}
3+
<label class="sr-only">
4+
{{ field.label }}
5+
</label>
6+
{% endif %}
7+
8+
<p class="form-control-static">Dictionaries are not currently supported in HTML input.</p>
9+
</div>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div class="form-group">
2+
{% if field.label %}
3+
<label class="sr-only">
4+
{{ field.label }}
5+
</label>
6+
{% endif %}
7+
8+
<p class="form-control-static">Lists are not currently supported in HTML input.</p>
9+
</div>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="form-group">
2+
{% if field.label %}
3+
<label {% if style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
4+
{% endif %}
5+
6+
<p class="form-control-static">Dictionaries are not currently supported in HTML input.</p>
7+
</div>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="form-group">
2+
{% if field.label %}
3+
<label {% if style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
4+
{% endif %}
5+
6+
<p class="form-control-static">Lists are not currently supported in HTML input.</p>
7+
</div>

0 commit comments

Comments
 (0)