Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field's show_hidden_initial property is not being respected #534

Closed
mick88 opened this issue May 17, 2021 · 3 comments
Closed

Field's show_hidden_initial property is not being respected #534

mick88 opened this issue May 17, 2021 · 3 comments

Comments

@mick88
Copy link

mick88 commented May 17, 2021

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

@mick88
Copy link
Author

mick88 commented May 17, 2021

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.

@dyve
Copy link
Member

dyve commented Aug 7, 2022

Reviving this. We should check this in 4 and 5 also. A (failing) unit test would help.

@dyve
Copy link
Member

dyve commented Apr 16, 2024

No further changes are expected on this project. See README.md (#964 ).

@dyve dyve closed this as completed Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants