Changeset 4147
- Timestamp:
- 11/30/06 11:48:54 (2 years ago)
- Files:
-
- django/trunk/tests/regressiontests/forms/tests.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/tests/regressiontests/forms/tests.py
r4146 r4147 4 4 >>> import datetime 5 5 >>> import re 6 7 ########### 8 # Widgets # 9 ########### 10 11 Each Widget class corresponds to an HTML form widget. A Widget knows how to 12 render itself, given a field name and some data. Widgets don't perform 13 validation. 6 14 7 15 # TextInput Widget ############################################################ … … 582 590 >>> w.render('nums', ['ŠĐĆŽćžšđ'], choices=[('ŠĐĆŽćžšđ', 'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')]) 583 591 u'<ul>\n<li><label><input type="checkbox" name="nums1" /> 1</label></li>\n<li><label><input type="checkbox" name="nums2" /> 2</label></li>\n<li><label><input type="checkbox" name="nums3" /> 3</label></li>\n<li><label><input checked="checked" type="checkbox" name="nums\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" /> \u0160\u0110abc\u0106\u017d\u0107\u017e\u0161\u0111</label></li>\n<li><label><input type="checkbox" name="nums\u0107\u017e\u0161\u0111" /> abc\u0107\u017e\u0161\u0111</label></li>\n</ul>' 592 593 ########## 594 # Fields # 595 ########## 596 597 Each Field class does some sort of validation. Each Field has a clean() method, 598 which either raises django.newforms.ValidationError or returns the "clean" 599 data -- usually a Unicode object, but, in some rare cases, a list. 600 601 Each Field's __init__() takes at least these parameters: 602 required -- Boolean that specifies whether the field is required. 603 True by default. 604 widget -- A Widget class, or instance of a Widget class, that should be 605 used for this Field when displaying it. Each Field has a default 606 Widget that it'll use if you don't specify this. In most cases, 607 the default widget is TextInput. 608 609 Other than that, the Field subclasses have class-specific options for 610 __init__(). For example, CharField has a max_length option. 584 611 585 612 # CharField ################################################################### … … 1238 1265 >>> f.clean(None) 1239 1266 u'' 1267 1268 ######### 1269 # Forms # 1270 ######### 1271 1272 A Form is a collection of Fields. It knows how to validate a set of data and it 1273 knows how to render itself in a couple of default ways (e.g., an HTML table). 1274 You can pass it data in __init__(), as a dictionary. 1240 1275 1241 1276 # Form ########################################################################
