Changeset 6564
- Timestamp:
- 10/20/07 07:21:16 (1 year ago)
- Files:
-
- django/trunk/docs/newforms.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/newforms.txt
r6532 r6564 101 101 message = forms.CharField() 102 102 sender = forms.EmailField() 103 cc_myself = forms.BooleanField( )103 cc_myself = forms.BooleanField(required=False) 104 104 105 105 A form is composed of ``Field`` objects. In this case, our form has four … … 1061 1061 ... message = forms.CharField() 1062 1062 ... sender = forms.EmailField(help_text='A valid e-mail address, please.') 1063 ... cc_myself = forms.BooleanField( )1063 ... cc_myself = forms.BooleanField(required=False) 1064 1064 >>> f = HelpTextContactForm(auto_id=False) 1065 1065 >>> print f.as_table() … … 1140 1140 1141 1141 * Default widget: ``CheckboxInput`` 1142 * Empty value: `` None``1142 * Empty value: ``False`` 1143 1143 * Normalizes to: A Python ``True`` or ``False`` value. 1144 * Validates nothing (i.e., it never raises a ``ValidationError``). 1144 * Validates that the check box is checked (i.e. the value is ``True``) if 1145 the field has ``required=True``. 1146 1147 **New in Django development version:** The empty value for a ``CheckboxInput`` 1148 (and hence the standard ``BooleanField``) has changed to return ``False`` 1149 instead of ``None`` in the development version. 1150 1151 .. note:: 1152 Since all ``Field`` subclasses have ``required=True`` by default, the 1153 validation condition here is important. If you want to include a checkbox 1154 in your form that can be either checked or unchecked, you must remember to 1155 pass in ``required=False`` when creating the ``BooleanField``. 1145 1156 1146 1157 ``CharField`` … … 1150 1161 * Empty value: ``''`` (an empty string) 1151 1162 * Normalizes to: A Unicode object. 1152 * Validates nothing, unless ``max_length`` or ``min_length`` is provided. 1163 * Validates ``max_length`` or ``min_length``, if they are provided. 1164 Otherwise, all inputs are valid. 1153 1165 1154 1166 Has two optional arguments for validation, ``max_length`` and ``min_length``. … … 1526 1538 message = forms.CharField() 1527 1539 senders = MultiEmailField() 1528 cc_myself = forms.BooleanField( )1540 cc_myself = forms.BooleanField(required=False) 1529 1541 1530 1542 Widgets … … 2051 2063 message = models.TextField() 2052 2064 sender = models.EmailField() 2053 cc_myself = models.BooleanField( )2065 cc_myself = models.BooleanField(required=False) 2054 2066 2055 2067 You could use this model to create a form (using ``form_for_model()``). You
