summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-03-18 14:20:43 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-03-18 14:20:43 +0000
commitec0bbc15a82cb1cf394a1296024b8e0b35d70728 (patch)
treee2ee77d38517f651934222df2070f2bae1e571d0 /django
parent4b9497c3f13d9fb410d552cfceaa98eafb2ffa10 (diff)
Fixed #6230: Fixed the addition of id values to the select widgets in
SelectDateWidget. Thanks, Matt McClanahan. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7291 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/newforms/extras/widgets.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/django/newforms/extras/widgets.py b/django/newforms/extras/widgets.py
index 0097ba3f54..af6b14b08d 100644
--- a/django/newforms/extras/widgets.py
+++ b/django/newforms/extras/widgets.py
@@ -39,21 +39,33 @@ class SelectDateWidget(Widget):
output = []
+ if 'id' in self.attrs:
+ id_ = self.attrs['id']
+ else:
+ id_ = 'id_%s' % name
+
month_choices = MONTHS.items()
month_choices.sort()
- select_html = Select(choices=month_choices).render(self.month_field % name, month_val)
+ local_attrs = self.build_attrs(id=self.month_field % id_)
+ select_html = Select(choices=month_choices).render(self.month_field % name, month_val, local_attrs)
output.append(select_html)
day_choices = [(i, i) for i in range(1, 32)]
- select_html = Select(choices=day_choices).render(self.day_field % name, day_val)
+ local_attrs['id'] = self.day_field % id_
+ select_html = Select(choices=day_choices).render(self.day_field % name, day_val, local_attrs)
output.append(select_html)
year_choices = [(i, i) for i in self.years]
- select_html = Select(choices=year_choices).render(self.year_field % name, year_val)
+ local_attrs['id'] = self.year_field % id_
+ select_html = Select(choices=year_choices).render(self.year_field % name, year_val, local_attrs)
output.append(select_html)
return mark_safe(u'\n'.join(output))
+ def id_for_label(self, id_):
+ return '%s_month' % id_
+ id_for_label = classmethod(id_for_label)
+
def value_from_datadict(self, data, files, name):
y, m, d = data.get(self.year_field % name), data.get(self.month_field % name), data.get(self.day_field % name)
if y and m and d: