Changeset 9565
- Timestamp:
- 12/03/08 23:39:50 (1 month ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/releases/1.0.X/docs/ref/forms/validation.txt
r9259 r9565 64 64 ``non_field_errors()`` method if you need to. If you want to attach 65 65 errors to a specific field in the form, you will need to access the 66 ` _errors` attribute on the form, which is `described later`_.66 ``_errors`` attribute on the form, which is `described later`_. 67 67 68 68 These methods are run in the order given above, one field at a time. That is, … … 100 100 101 101 When you really do need to attach the error to a particular field, you should 102 store (or amend) a key in the ` Form._errors` attribute. This attribute is an102 store (or amend) a key in the ``Form._errors`` attribute. This attribute is an 103 103 instance of a ``django.forms.util.ErrorDict`` class. Essentially, though, it's 104 104 just a dictionary. There is a key in the dictionary for each field in the form 105 105 that has an error. Each value in the dictionary is a 106 106 ``django.forms.util.ErrorList`` instance, which is a list that knows how to 107 display itself in different ways. So you can treat ` _errors` as a dictionary107 display itself in different ways. So you can treat ``_errors`` as a dictionary 108 108 mapping field names to lists. 109 109 110 110 If you want to add a new error to a particular field, you should check whether 111 the key already exists in ` self._errors` or not. If not, create a new entry111 the key already exists in ``self._errors`` or not. If not, create a new entry 112 112 for the given key, holding an empty ``ErrorList`` instance. In either case, 113 113 you can then append your error message to the list for the field name in 114 114 question and it will be displayed when the form is displayed. 115 115 116 There is an example of modifying ` self._errors` in the following section.116 There is an example of modifying ``self._errors`` in the following section. 117 117 118 118 .. admonition:: What's in a name?
