Ticket #12466: patch_css_classes.3.diff
File patch_css_classes.3.diff, 2.7 KB (added by , 15 years ago) |
---|
-
django/forms/forms.py
137 137 "Helper function for outputting HTML. Used by as_table(), as_ul(), as_p()." 138 138 top_errors = self.non_field_errors() # Errors that should be displayed above all fields. 139 139 output, hidden_fields = [], [] 140 html_class_attr = ''141 140 142 141 for name, field in self.fields.items(): 142 html_class_attr = '' 143 143 bf = BoundField(self, field, name) 144 144 bf_errors = self.error_class([conditional_escape(error) for error in bf.errors]) # Escape and cache in local variable. 145 145 if bf.is_hidden: -
tests/regressiontests/forms/forms.py
1816 1816 1817 1817 # The error_html_class and required_html_class attributes #################### 1818 1818 1819 >>> class Person(Form): 1820 ... name = CharField() 1821 ... is_cool = NullBooleanField() 1822 ... email = EmailField(required=False) 1823 ... age = IntegerField() 1824 1819 1825 >>> p = Person({}) 1820 1826 >>> p.error_css_class = 'error' 1821 1827 >>> p.required_css_class = 'required' … … 1827 1833 <option value="2">Yes</option> 1828 1834 <option value="3">No</option> 1829 1835 </select></li> 1836 <li><label for="id_email">Email:</label> <input type="text" name="email" id="id_email" /></li> 1837 <li class="required error"><ul class="errorlist"><li>This field is required.</li></ul><label for="id_age">Age:</label> <input type="text" name="age" id="id_age" /></li> 1830 1838 1831 1839 >>> print p.as_p() 1832 1840 <ul class="errorlist"><li>This field is required.</li></ul> … … 1836 1844 <option value="2">Yes</option> 1837 1845 <option value="3">No</option> 1838 1846 </select></p> 1847 <p><label for="id_email">Email:</label> <input type="text" name="email" id="id_email" /></p> 1848 <ul class="errorlist"><li>This field is required.</li></ul> 1849 <p class="required error"><label for="id_age">Age:</label> <input type="text" name="age" id="id_age" /></p> 1839 1850 1840 1851 >>> print p.as_table() 1841 1852 <tr class="required error"><th><label for="id_name">Name:</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="name" id="id_name" /></td></tr> … … 1844 1855 <option value="2">Yes</option> 1845 1856 <option value="3">No</option> 1846 1857 </select></td></tr> 1858 <tr><th><label for="id_email">Email:</label></th><td><input type="text" name="email" id="id_email" /></td></tr> 1859 <tr class="required error"><th><label for="id_age">Age:</label></th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="age" id="id_age" /></td></tr> 1847 1860 1848 1861 1849 1862 """