Fixed #27431 -- Prevented disabled form fields from appearing as changed.
This commit is contained in:
parent
7b05ffd95d
commit
8618a7eaa1
|
@ -187,6 +187,10 @@ class Field(object):
|
||||||
"""
|
"""
|
||||||
Return True if data differs from initial.
|
Return True if data differs from initial.
|
||||||
"""
|
"""
|
||||||
|
# Always return False if the field is disabled since self.bound_data
|
||||||
|
# always uses the initial value in this case.
|
||||||
|
if self.disabled:
|
||||||
|
return False
|
||||||
try:
|
try:
|
||||||
data = self.to_python(data)
|
data = self.to_python(data)
|
||||||
if hasattr(self, '_coerce'):
|
if hasattr(self, '_coerce'):
|
||||||
|
|
|
@ -34,3 +34,9 @@ class BasicFieldsTests(SimpleTestCase):
|
||||||
f.fields['field2'].choices = [('2', '2')]
|
f.fields['field2'].choices = [('2', '2')]
|
||||||
self.assertEqual(f.fields['field1'].widget.choices, [('1', '1')])
|
self.assertEqual(f.fields['field1'].widget.choices, [('1', '1')])
|
||||||
self.assertEqual(f.fields['field2'].widget.choices, [('2', '2')])
|
self.assertEqual(f.fields['field2'].widget.choices, [('2', '2')])
|
||||||
|
|
||||||
|
|
||||||
|
class DisabledFieldTests(SimpleTestCase):
|
||||||
|
def test_disabled_field_has_changed_always_false(self):
|
||||||
|
disabled_field = Field(disabled=True)
|
||||||
|
self.assertFalse(disabled_field.has_changed('x', 'y'))
|
||||||
|
|
Loading…
Reference in New Issue