Ticket #12466: patch_css_classes.2.diff
File patch_css_classes.2.diff, 2.2 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 1819 1824 >>> p = Person({}) 1820 1825 >>> p.error_css_class = 'error' 1821 1826 >>> p.required_css_class = 'required' … … 1827 1832 <option value="2">Yes</option> 1828 1833 <option value="3">No</option> 1829 1834 </select></li> 1835 <li><label for="id_email">Email:</label> <input type="text" name="email" id="id_email" /></li> 1830 1836 1831 1837 >>> print p.as_p() 1832 1838 <ul class="errorlist"><li>This field is required.</li></ul> … … 1836 1842 <option value="2">Yes</option> 1837 1843 <option value="3">No</option> 1838 1844 </select></p> 1845 <p><label for="id_email">Email:</label> <input type="text" name="email" id="id_email" /></p> 1839 1846 1840 1847 >>> print p.as_table() 1841 1848 <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 1851 <option value="2">Yes</option> 1845 1852 <option value="3">No</option> 1846 1853 </select></td></tr> 1854 <tr><th><label for="id_email">Email:</label></th><td><input type="text" name="email" id="id_email" /></td></tr> 1847 1855 1848 1856 1849 1857 """