Opened 9 years ago

Closed 9 years ago

#26534 closed Bug (fixed)

has_changed For BooleanField and NullBooelanField always returns True with HiddenInput

Reported by: David Sanders Owned by: nobody
Component: Forms Version: dev
Severity: Normal Keywords: has_changed BooleanField
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

The current implementation of has_changed for both forms.BooleanField and forms.NullBooleanField will always return True if a HiddenInput is used because the raw value is "True" or "False" and has_changed isn't running to_python before comparing them.

I've got a pull request that adds test coverage and fixes the issue by running the data to has_changed through to_python before comparing to the initial value. This should cover other widgets beyond HiddenInput as long as they return a value understood by to_python for forms.BooleanField and forms.NullBooleanField.

Change History (3)

comment:1 by Simon Charette, 9 years ago

Version: 1.8master

comment:2 by Simon Charette, 9 years ago

Triage Stage: UnreviewedReady for checkin

comment:3 by Simon Charette <charettes@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 218175b0:

Fixed #26534 -- Fixed boolean form fields has_changed() with hidden input.

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