mirror of
				https://github.com/django/django.git
				synced 2025-10-30 17:16:10 +00:00 
			
		
		
		
	Fixed #11632: Fixed the id for hidden initial widget so that it is different from the id for its visible counterpart. Thanks geber@datacollect.com and Mark Lavin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11826 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
		
							
								
								
									
										2
									
								
								AUTHORS
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								AUTHORS
									
									
									
									
									
								
							| @@ -173,6 +173,7 @@ answer newbie questions, and generally made Django that much better: | |||||||
|     Alex Gaynor <alex.gaynor@gmail.com> |     Alex Gaynor <alex.gaynor@gmail.com> | ||||||
|     Andy Gayton <andy-django@thecablelounge.com> |     Andy Gayton <andy-django@thecablelounge.com> | ||||||
|     Idan Gazit |     Idan Gazit | ||||||
|  |     geber@datacollect.com | ||||||
|     Baishampayan Ghose |     Baishampayan Ghose | ||||||
|     Dimitris Glezos <dimitris@glezos.com> |     Dimitris Glezos <dimitris@glezos.com> | ||||||
|     glin@seznam.cz |     glin@seznam.cz | ||||||
| @@ -268,6 +269,7 @@ answer newbie questions, and generally made Django that much better: | |||||||
|     Finn Gruwier Larsen <finn@gruwier.dk> |     Finn Gruwier Larsen <finn@gruwier.dk> | ||||||
|     Lau Bech Lauritzen |     Lau Bech Lauritzen | ||||||
|     Rune Rønde Laursen <runerl@skjoldhoej.dk> |     Rune Rønde Laursen <runerl@skjoldhoej.dk> | ||||||
|  |     Mark Lavin <markdlavin@gmail.com> | ||||||
|     Eugene Lazutkin <http://lazutkin.com/blog/> |     Eugene Lazutkin <http://lazutkin.com/blog/> | ||||||
|     lcordier@point45.com |     lcordier@point45.com | ||||||
|     Jeong-Min Lee <falsetru@gmail.com> |     Jeong-Min Lee <falsetru@gmail.com> | ||||||
|   | |||||||
| @@ -343,6 +343,7 @@ class BoundField(StrAndUnicode): | |||||||
|         self.name = name |         self.name = name | ||||||
|         self.html_name = form.add_prefix(name) |         self.html_name = form.add_prefix(name) | ||||||
|         self.html_initial_name = form.add_initial_prefix(name) |         self.html_initial_name = form.add_initial_prefix(name) | ||||||
|  |         self.html_initial_id = form.add_initial_prefix(self.auto_id) | ||||||
|         if self.field.label is None: |         if self.field.label is None: | ||||||
|             self.label = pretty_name(name) |             self.label = pretty_name(name) | ||||||
|         else: |         else: | ||||||
| @@ -374,7 +375,10 @@ class BoundField(StrAndUnicode): | |||||||
|         attrs = attrs or {} |         attrs = attrs or {} | ||||||
|         auto_id = self.auto_id |         auto_id = self.auto_id | ||||||
|         if auto_id and 'id' not in attrs and 'id' not in widget.attrs: |         if auto_id and 'id' not in attrs and 'id' not in widget.attrs: | ||||||
|  |             if not only_initial: | ||||||
|                 attrs['id'] = auto_id |                 attrs['id'] = auto_id | ||||||
|  |             else: | ||||||
|  |                 attrs['id'] = self.html_initial_id | ||||||
|         if not self.form.is_bound: |         if not self.form.is_bound: | ||||||
|             data = self.form.initial.get(self.name, self.field.initial) |             data = self.form.initial.get(self.name, self.field.initial) | ||||||
|             if callable(data): |             if callable(data): | ||||||
|   | |||||||
| @@ -1807,4 +1807,11 @@ True | |||||||
| >>> [f.name for f in form.visible_fields()] | >>> [f.name for f in form.visible_fields()] | ||||||
| ['artist', 'name'] | ['artist', 'name'] | ||||||
|  |  | ||||||
|  | # Hidden initial input gets its own unique id ################################ | ||||||
|  |  | ||||||
|  | >>> class MyForm(Form): | ||||||
|  | ...     field1 = CharField(max_length=50, show_hidden_initial=True) | ||||||
|  | >>> print MyForm() | ||||||
|  | <tr><th><label for="id_field1">Field1:</label></th><td><input id="id_field1" type="text" name="field1" maxlength="50" /><input type="hidden" name="initial-field1" id="initial-id_field1" /></td></tr> | ||||||
|  |  | ||||||
| """ | """ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user