Opened 8 years ago

Closed 8 years ago

#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 by Kenneth Veldman, 8 years ago

Owner: changed from nobody to Kenneth Veldman
Status: newassigned

comment:2 by Kenneth Veldman, 8 years ago

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 by Kenneth Veldman, 8 years ago

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 8 years ago by Tim Graham (previous) (diff)

comment:4 by Mariusz Felisiak, 8 years ago

Patch needs improvement: set

comment:5 by Kenneth Veldman, 8 years ago

Patch needs improvement: unset

Patch has been improved.

comment:6 by Mariusz Felisiak, 8 years ago

Triage Stage: AcceptedReady for checkin

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

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