Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#26129 closed Bug (fixed)

bound forms do not display disabled field initial values

Reported by: Gerald Thibault Owned by: Tim Graham
Component: Forms Version: 1.9
Severity: Release blocker Keywords: disabled fields, forms
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The subject pretty much says it all. If you create a form with an initial value for a disabled field, it displays fine as long as the form is unbound. If a user submits the form, and it fails validation, the rendered bound form will be missing the initial values for the disabled fields.

I would expect the disabled fields to always display the contents from the form's "initial" dict, whether bound or unbound. The user is unable to submit values for that field, and even if he/she tampered with the DOM and managed to push something through, _clean_fields still loads the initial value and then assigns it to cleaned_data. So the handling is correct, but that value never ends up in the rendered field. 'initial' is the only possible source for that field, so it seems it should display all the time.

I attached a test file that illustrates the issue.

Attachments (2)

disabled.py (1.2 KB ) - added by Gerald Thibault 8 years ago.
An example of a disabled field displaying the value in an unbound form, but omitting the value in a bound form.
26129-test.diff (823 bytes ) - added by Tim Graham 8 years ago.

Download all attachments as: .zip

Change History (7)

by Gerald Thibault, 8 years ago

Attachment: disabled.py added

An example of a disabled field displaying the value in an unbound form, but omitting the value in a bound form.

comment:1 by Tim Graham, 8 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

Seems to be an important bug in a new feature in 1.9 (#25078). Possible test attached -- may need to be adjusted depending on the actual solution.

by Tim Graham, 8 years ago

Attachment: 26129-test.diff added

comment:2 by Tim Graham, 8 years ago

Owner: changed from nobody to Tim Graham
Status: newassigned

comment:3 by Tim Graham, 8 years ago

Has patch: set

comment:4 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 04564eb:

Fixed #26129 -- Made invalid forms display initial values of disabled fields.

comment:5 by Tim Graham <timograham@…>, 8 years ago

In 01db324:

[1.9.x] Fixed #26129 -- Made invalid forms display initial values of disabled fields.

Backport of 04564eb74d2d92eaf88b22ab8cec7ef45978111e from master

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