--- /home/mammique/Desktop/widgets.py	2007-11-16 22:31:38.000000000 +0100
+++ ../django-trunk/django/newforms/extras/widgets.py	2007-11-16 22:39:18.000000000 +0100
@@ -30,8 +30,17 @@
             self.years = range(this_year, this_year+10)
 
     def render(self, name, value, attrs=None):
+
+        has_id = attrs and 'id' in attrs
+        final_attrs = self.build_attrs(attrs, name=name)
+
+        def select_id(name_field):
+            if has_id: return dict(final_attrs, id=name_field % attrs['id'])
+            else: return None
+
         try:
-            value = datetime.date(*map(int, value.split('-')))
+            if isinstance(value, unicode):
+                value = datetime.date(*map(int, value.split('-')))
             year_val, month_val, day_val = value.year, value.month, value.day
         except (AttributeError, TypeError, ValueError):
             year_val = month_val = day_val = None
@@ -40,15 +49,18 @@
 
         month_choices = MONTHS.items()
         month_choices.sort()
-        select_html = Select(choices=month_choices).render(self.month_field % name, month_val)
+        select_html = Select(select_id(self.month_field),
+                             choices=month_choices).render(self.month_field % name, month_val)
         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)
+        select_html = Select(select_id(self.month_field),
+                             choices=day_choices).render(self.day_field % name, day_val)
         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)
+        select_html = Select(select_id(self.year_field),
+                             choices=year_choices).render(self.year_field % name, year_val)
         output.append(select_html)
 
         return u'\n'.join(output)
