mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Fixed #17922 -- Added required_css_class to form label.
Thanks hanson2010 for the suggestion.
This commit is contained in:
		
				
					committed by
					
						 Tim Graham
						Tim Graham
					
				
			
			
				
	
			
			
			
						parent
						
							2ec82c7387
						
					
				
				
					commit
					416a858023
				
			| @@ -621,6 +621,12 @@ class BoundField(object): | ||||
|             id_for_label = widget.id_for_label(id_) | ||||
|             if id_for_label: | ||||
|                 attrs = dict(attrs or {}, **{'for': id_for_label}) | ||||
|             if self.field.required and hasattr(self.form, 'required_css_class'): | ||||
|                 attrs = attrs or {} | ||||
|                 if 'class' in attrs: | ||||
|                     attrs['class'] += ' ' + self.form.required_css_class | ||||
|                 else: | ||||
|                     attrs['class'] = self.form.required_css_class | ||||
|             attrs = flatatt(attrs) if attrs else '' | ||||
|             contents = format_html('<label{0}>{1}</label>', attrs, contents) | ||||
|         else: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user