#27431 closed Bug (fixed)

Disabled fields are marked as changed in form

Reported by: Paul Owned by: Kenneth Veldman
Component: Forms Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If field has initial value and is marked as disabled, then it will be marked as changed after form submission.

Change History (7)

comment:1 Changed 21 months ago by Kenneth Veldman

Owner: changed from nobody to Kenneth Veldman
Status: newassigned

comment:2 Changed 21 months ago by Kenneth Veldman

Triage Stage: UnreviewedAccepted

Able to reproduce using a form on submit using a simple form with two comparable fields.

Code highlighting:

class TestForm(forms.Form):
    test_disabled = forms.CharField(disabled=True, initial='test')
    test_enabled = forms.CharField(disabled=False, initial='test')

Results of form.has_changed() and form.changed_data after the form has been submitted are:

Code highlighting:

form.has_changed()  # True
form.changed_data  # ['test_disabled']

Working on writing a patch.

comment:3 Changed 21 months ago by Kenneth Veldman

Has patch: set

PR

Added a check in the has_changed function of a field to see if a field is disabled and always return true.

All test pass under SQLite.

Last edited 21 months ago by Tim Graham (previous) (diff)

comment:4 Changed 21 months ago by felixxm

Patch needs improvement: set

comment:5 Changed 21 months ago by Kenneth Veldman

Patch needs improvement: unset

Patch has been improved.

comment:6 Changed 21 months ago by felixxm

Triage Stage: AcceptedReady for checkin

comment:7 Changed 20 months ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 8618a7e:

Fixed #27431 -- Prevented disabled form fields from appearing as changed.

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