mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
Made TemplateHTMLRenderer render IntegerField inputs when value is 0
. (#5834)
* Fix 0 value IntegerField in TemplateHTMLRenderer Signed-off-by: Nikhil Sheoran <nikhilsheoran96@gmail.com> * Remove unnecessary `field.value != “”` check * Adjust test case Uses `vertical` templates only.
This commit is contained in:
parent
da535d31dd
commit
e34fd995cd
|
@ -6,7 +6,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input name="{{ field.name }}" {% if style.input_type != "file" %}class="form-control"{% endif %} type="{{ style.input_type }}" {% if style.placeholder %}placeholder="{{ style.placeholder }}"{% endif %} {% if field.value %}value="{{ field.value }}"{% endif %} {% if style.autofocus and style.input_type != "hidden" %}autofocus{% endif %}>
|
<input name="{{ field.name }}" {% if style.input_type != "file" %}class="form-control"{% endif %} type="{{ style.input_type }}" {% if style.placeholder %}placeholder="{{ style.placeholder }}"{% endif %} {% if field.value is not None %}value="{{ field.value }}"{% endif %} {% if style.autofocus and style.input_type != "hidden" %}autofocus{% endif %}>
|
||||||
|
|
||||||
{% if field.errors %}
|
{% if field.errors %}
|
||||||
{% for error in field.errors %}
|
{% for error in field.errors %}
|
||||||
|
|
|
@ -5,5 +5,5 @@
|
||||||
</label>
|
</label>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<input name="{{ field.name }}" {% if style.input_type != "file" %}class="form-control"{% endif %} type="{{ style.input_type }}" {% if style.placeholder %}placeholder="{{ style.placeholder }}"{% endif %} {% if field.value %}value="{{ field.value }}"{% endif %} {% if style.autofocus and style.input_type != "hidden" %}autofocus{% endif %}>
|
<input name="{{ field.name }}" {% if style.input_type != "file" %}class="form-control"{% endif %} type="{{ style.input_type }}" {% if style.placeholder %}placeholder="{{ style.placeholder }}"{% endif %} {% if field.value is not None %}value="{{ field.value }}"{% endif %} {% if style.autofocus and style.input_type != "hidden" %}autofocus{% endif %}>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<label {% if style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
|
<label {% if style.hide_label %}class="sr-only"{% endif %}>{{ field.label }}</label>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<input name="{{ field.name }}" {% if style.input_type != "file" %}class="form-control"{% endif %} type="{{ style.input_type }}" {% if style.placeholder %}placeholder="{{ style.placeholder }}"{% endif %} {% if field.value %}value="{{ field.value }}"{% endif %} {% if style.autofocus and style.input_type != "hidden" %}autofocus{% endif %}>
|
<input name="{{ field.name }}" {% if style.input_type != "file" %}class="form-control"{% endif %} type="{{ style.input_type }}" {% if style.placeholder %}placeholder="{{ style.placeholder }}"{% endif %} {% if field.value is not None %}value="{{ field.value }}"{% endif %} {% if style.autofocus and style.input_type != "hidden" %}autofocus{% endif %}>
|
||||||
|
|
||||||
{% if field.errors %}
|
{% if field.errors %}
|
||||||
{% for error in field.errors %}
|
{% for error in field.errors %}
|
||||||
|
|
|
@ -151,7 +151,7 @@ class TestNestedBoundField:
|
||||||
'<legend>Nested1</legend>'
|
'<legend>Nested1</legend>'
|
||||||
'<divclass="form-group">'
|
'<divclass="form-group">'
|
||||||
'<label>Textfield</label>'
|
'<label>Textfield</label>'
|
||||||
'<inputname="nested2.nested1.text_field"class="form-control"type="text">'
|
'<inputname="nested2.nested1.text_field"class="form-control"type="text"value="">'
|
||||||
'</div>'
|
'</div>'
|
||||||
'</fieldset>'
|
'</fieldset>'
|
||||||
'<divclass="form-group">'
|
'<divclass="form-group">'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user