Opened 8 years ago

Closed 8 years ago

#15256 closed (invalid)

FormSet does not respect initial values after binding

Reported by: mnbayazit Owned by: nobody
Component: Forms Version: master
Severity: Keywords: formset
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Russell Keith-Magee)

After the form is posted, if an empty form is generated, it will be completely empty rather than having the initial values specified on the form. I believe we can fix this by modifying _construct_form like so:

        if self.is_bound and i < self.initial_form_count():
            defaults['data'] =
            defaults['files'] = self.files

And completely remove this chunk from _get_empty_form

        if self.is_bound:
            defaults['data'] =
            defaults['files'] = self.files

I don't know why an empty form should behave any differently after the formset has been bound... it only seems to be causing problems.

Change History (2)

comment:1 in reply to:  description Changed 8 years ago by mnbayazit

Nevermind... I don't my proposed fix works that well. But this is still a bug and I don't know how to get around it :\

comment:2 Changed 8 years ago by Russell Keith-Magee

Description: modified (diff)
Resolution: invalid
Status: newclosed

When providing a bug report, you should spend less time tell us how to fix the problem, and more time explaining the problem itself. If you're going to provide a code sample, make it a code sample that demonstrates the problem.

I can't work out how to reproduce the problem from the instructions provided; closing invalid. Feel free to reopen if you want to provide a reproducible test case.

Note: See TracTickets for help on using tickets.
Back to Top