mirror of
				https://github.com/django/django.git
				synced 2025-10-30 00:56:09 +00:00 
			
		
		
		
	Fixed #22684 -- Added empty_label option on django.forms.extras.widets.SelectDateWidget
				
					
				
			Thanks danielsamuels for the report
This commit is contained in:
		
				
					committed by
					
						 Tim Graham
						Tim Graham
					
				
			
			
				
	
			
			
			
						parent
						
							fd427f1fe3
						
					
				
				
					commit
					32586b0ba4
				
			| @@ -48,7 +48,7 @@ class SelectDateWidget(Widget): | ||||
|     day_field = '%s_day' | ||||
|     year_field = '%s_year' | ||||
|  | ||||
|     def __init__(self, attrs=None, years=None, months=None): | ||||
|     def __init__(self, attrs=None, years=None, months=None, empty_label=None): | ||||
|         self.attrs = attrs or {} | ||||
|  | ||||
|         # Optional list or tuple of years to use in the "year" select box. | ||||
| @@ -64,6 +64,9 @@ class SelectDateWidget(Widget): | ||||
|         else: | ||||
|             self.months = MONTHS | ||||
|  | ||||
|         if empty_label is not None: | ||||
|             self.none_value = (0, empty_label) | ||||
|  | ||||
|     def render(self, name, value, attrs=None): | ||||
|         try: | ||||
|             year_val, month_val, day_val = value.year, value.month, value.day | ||||
|   | ||||
		Reference in New Issue
	
	Block a user