1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

newforms: Fixed confusing behavior when setting choices for ChoiceFields and their corresponding Widgets. Now, a Widget uses the choices from its ChoiceField regardless of whether the Widget has its own choices.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4378 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty
2007-01-21 01:10:55 +00:00
parent c770803f72
commit f073318668
2 changed files with 38 additions and 1 deletions

View File

@@ -319,7 +319,8 @@ class BooleanField(Field):
class ChoiceField(Field):
def __init__(self, choices=(), required=True, widget=Select, label=None, initial=None):
if isinstance(widget, type):
widget = widget(choices=choices)
widget = widget()
widget.choices = choices
super(ChoiceField, self).__init__(required, widget, label, initial)
self.choices = choices