Ticket #3787: widgets_multiwidget.patch
File widgets_multiwidget.patch, 1.1 KB (added by , 18 years ago) |
---|
-
widgets.py
317 317 if not isinstance(value, list): 318 318 value = self.decompress(value) 319 319 output = [] 320 has_id = attrs.get('id', False) 320 321 for i, widget in enumerate(self.widgets): 321 322 try: 322 323 widget_value = value[i] 323 except KeyError:324 except IndexError: 324 325 widget_value = None 326 if has_id: 327 attrs = dict(attrs, id='%s_%s' % (has_id, i)) 325 328 output.append(widget.render(name + '_%s' % i, widget_value, attrs)) 326 329 return self.format_output(output) 327 330 328 331 def value_from_datadict(self, data, name): 329 return [ data.get(name + '_%s' % i) for i in range(len(self.widgets))]332 return [self.widgets[i].value_from_datadict(data, name + '_%s' % i) for i in range(len(self.widgets))] 330 333 331 334 def format_output(self, rendered_widgets): 332 335 return u''.join(rendered_widgets)