Ticket #3686: required_label.diff
File required_label.diff, 2.1 KB (added by , 18 years ago) |
---|
-
django/newforms/forms.py
121 121 else: 122 122 if errors_on_separate_row and bf_errors: 123 123 output.append(error_row % bf_errors) 124 label = bf.label and bf.label_tag(escape(bf.label + ':')) or '' 124 attrs = field.required and {'class': 'required'} or None 125 label = bf.label and bf.label_tag(escape(bf.label + ':'), attrs=attrs) or '' 125 126 if field.help_text: 126 127 help_text = help_text_html % field.help_text 127 128 else: -
tests/modeltests/model_forms/models.py
71 71 >>> CategoryForm = form_for_model(Category) 72 72 >>> f = CategoryForm() 73 73 >>> print f 74 <tr><th><label for="id_name" >Name:</label></th><td><input id="id_name" type="text" name="name" maxlength="20" /></td></tr>75 <tr><th><label for="id_url" >The URL:</label></th><td><input id="id_url" type="text" name="url" maxlength="40" /></td></tr>74 <tr><th><label for="id_name" class="required">Name:</label></th><td><input id="id_name" type="text" name="name" maxlength="20" /></td></tr> 75 <tr><th><label for="id_url" class="required">The URL:</label></th><td><input id="id_url" type="text" name="url" maxlength="40" /></td></tr> 76 76 >>> print f.as_ul() 77 <li><label for="id_name" >Name:</label> <input id="id_name" type="text" name="name" maxlength="20" /></li>78 <li><label for="id_url" >The URL:</label> <input id="id_url" type="text" name="url" maxlength="40" /></li>77 <li><label for="id_name" class="required">Name:</label> <input id="id_name" type="text" name="name" maxlength="20" /></li> 78 <li><label for="id_url" class="required">The URL:</label> <input id="id_url" type="text" name="url" maxlength="40" /></li> 79 79 >>> print f['name'] 80 80 <input id="id_name" type="text" name="name" maxlength="20" /> 81 81