Opened 4 years ago

Closed 4 years ago

Last modified 4 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 4 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 4 years ago.

Download all attachments as: .zip

Change History (7)

Changed 4 years ago by Gerald Thibault

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 Changed 4 years ago by Tim Graham

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.

Changed 4 years ago by Tim Graham

Attachment: 26129-test.diff added

comment:2 Changed 4 years ago by Tim Graham

Owner: changed from nobody to Tim Graham
Status: newassigned

comment:3 Changed 4 years ago by Tim Graham

Has patch: set

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

Resolution: fixed
Status: assignedclosed

In 04564eb:

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

comment:5 Changed 4 years ago by Tim Graham <timograham@…>

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