Index: tests/regressiontests/forms/tests.py
===================================================================
--- tests/regressiontests/forms/tests.py (revision 4357)
+++ tests/regressiontests/forms/tests.py (working copy)
@@ -2063,6 +2063,8 @@
>>> f.clean_data
{'username': u'adrian', 'password1': u'foo', 'password2': u'foo'}
+# Dynamic construction ########################################################
+
It's possible to construct a Form dynamically by adding to the self.fields
dictionary in __init__(). Don't forget to call Form.__init__() within the
subclass' __init__().
@@ -2078,6 +2080,25 @@
Last name:
Birthday:
+Instances of a dynamic form should not persist fields from one
+form instance to the next
+>>> class MyForm(Form):
+... def __init__(self, data=None, auto_id=False, field_list=[]):
+... Form.__init__(self, data, auto_id)
+... for field in field_list:
+... self.fields[field[0]] = field[1]
+...
+>>> field_list = ( ('field1', CharField()), ('field2', CharField()) )
+>>> my_form = MyForm(field_list=field_list)
+>>> print my_form
+
+
HiddenInput widgets are displayed differently in the as_table(), as_ul()
and as_p() output of a Form -- their verbose names are not displayed, and a
separate row is not displayed. They're displayed in the last row of the