From 8bb3763c2bb6ae53e2ce36c5f2ed3c3e4545c90f Mon Sep 17 00:00:00 2001 From: Karen Tracey Date: Sat, 12 Dec 2009 18:22:09 +0000 Subject: [1.1.X] 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. r11826 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@11827 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/forms/forms.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'django/forms/forms.py') diff --git a/django/forms/forms.py b/django/forms/forms.py index 0b7c2e2338..705058a6e6 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -343,6 +343,7 @@ class BoundField(StrAndUnicode): self.name = name self.html_name = form.add_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: self.label = pretty_name(name) else: @@ -374,7 +375,10 @@ class BoundField(StrAndUnicode): attrs = attrs or {} auto_id = self.auto_id if auto_id and 'id' not in attrs and 'id' not in widget.attrs: - attrs['id'] = auto_id + if not only_initial: + attrs['id'] = auto_id + else: + attrs['id'] = self.html_initial_id if not self.form.is_bound: data = self.form.initial.get(self.name, self.field.initial) if callable(data): -- cgit v1.3