django-bootstrap3
django-bootstrap3 copied to clipboard
Field's `show_hidden_initial` property is not being respected
Django form field has a property that can be set in constructor:
# show_hidden_initial -- Boolean that specifies if it is needed to render a
# hidden widget with initial value after widget.
When bound field is rendered by Django, it is used to append a hidden field containing the default value:
def __str__(self):
"""Render this field as an HTML widget."""
if self.field.show_hidden_initial:
return self.as_widget() + self.as_hidden(only_initial=True)
return self.as_widget()
However, when rendering form using FieldRenderer
, this functionality is broken. As a result, form's changed_values
contains the field even if it was not actually changed by user (assuming it already has a value)
Affected versions: Django 2.2.23 django-bootstrap3 15.0.0
The linked Pull Request fixes the issue for me in django 2.2. I have not tested other Django versions, but show_hidden_initial
and implementetion of field render is the same in Django 2.2 and 3.2, so the fix should work for all supported versions of Django.
Reviving this. We should check this in 4 and 5 also. A (failing) unit test would help.
No further changes are expected on this project. See README.md (https://github.com/zostera/django-bootstrap3/pull/964 ).