summaryrefslogtreecommitdiff
path: root/tests/regressiontests/forms
diff options
context:
space:
mode:
Diffstat (limited to 'tests/regressiontests/forms')
-rw-r--r--tests/regressiontests/forms/tests/forms.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/tests/forms.py b/tests/regressiontests/forms/tests/forms.py
index b52a0537ee..91a7472cd1 100644
--- a/tests/regressiontests/forms/tests/forms.py
+++ b/tests/regressiontests/forms/tests/forms.py
@@ -1151,6 +1151,21 @@ class FormsTestCase(TestCase):
<option value="w">whiz</option>
</select></li>""")
+ def test_boundfield_values(self):
+ # It's possible to get to the value which would be used for rendering
+ # the widget for a field by using the BoundField's value method.
+
+ class UserRegistration(Form):
+ username = CharField(max_length=10, initial='djangonaut')
+ password = CharField(widget=PasswordInput)
+
+ unbound = UserRegistration()
+ bound = UserRegistration({'password': 'foo'})
+ self.assertEqual(bound['username'].value(), None)
+ self.assertEqual(unbound['username'].value(), 'djangonaut')
+ self.assertEqual(bound['password'].value(), 'foo')
+ self.assertEqual(unbound['password'].value(), None)
+
def test_help_text(self):
# You can specify descriptive text for a field by using the 'help_text' argument)
class UserRegistration(Form):