Skip to content

Commit

Permalink
Disable HTML inputs for dict/list fields (encode#5702)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan P Kilby authored and Pierre Chiquet committed Mar 24, 2020
1 parent 5751d58 commit 2c5476e
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rest_framework/renderers.py
Expand Up @@ -320,6 +320,12 @@ class HTMLFormRenderer(BaseRenderer):
serializers.ListSerializer: {
'base_template': 'list_fieldset.html'
},
serializers.ListField: {
'base_template': 'list_field.html'
},
serializers.DictField: {
'base_template': 'dict_field.html'
},
serializers.FilePathField: {
'base_template': 'select.html',
},
Expand Down
11 changes: 11 additions & 0 deletions rest_framework/templates/rest_framework/horizontal/dict_field.html
@@ -0,0 +1,11 @@
<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">
<p class="form-control-static">Dictionaries are not currently supported in HTML input.</p>
</div>
</div>
11 changes: 11 additions & 0 deletions rest_framework/templates/rest_framework/horizontal/list_field.html
@@ -0,0 +1,11 @@
<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">
<p class="form-control-static">Lists are not currently supported in HTML input.</p>
</div>
</div>
@@ -0,0 +1,9 @@
<div class="form-group">
{% if field.label %}
<label class="sr-only">
{{ field.label }}
</label>
{% endif %}

<p class="form-control-static">Dictionaries are not currently supported in HTML input.</p>
</div>
@@ -0,0 +1,9 @@
<div class="form-group">
{% if field.label %}
<label class="sr-only">
{{ field.label }}
</label>
{% endif %}

<p class="form-control-static">Lists are not currently supported in HTML input.</p>
</div>
@@ -0,0 +1,7 @@
<div class="form-group">
{% if field.label %}
<label {% if style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
{% endif %}

<p class="form-control-static">Dictionaries are not currently supported in HTML input.</p>
</div>
@@ -0,0 +1,7 @@
<div class="form-group">
{% if field.label %}
<label {% if style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
{% endif %}

<p class="form-control-static">Lists are not currently supported in HTML input.</p>
</div>

0 comments on commit 2c5476e

Please sign in to comment.