From 76f6dd42cc3c763d9f64c2c8f74f244613ae771b Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sun, 21 Jan 2007 01:29:01 +0000 Subject: Fixed #3196 -- Fixed inconsistency in setting choices on ChoiceFields dynamically git-svn-id: http://code.djangoproject.com/svn/django/trunk@4379 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/forms/tests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/regressiontests/forms') diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index b1425bef6d..5f003711dc 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -1866,6 +1866,21 @@ defined on the Field, not the ones defined on the Widget. +You can set a ChoiceField's choices after the fact. +>>> class FrameworkForm(Form): +... name = CharField() +... language = ChoiceField() +>>> f = FrameworkForm(auto_id=False) +>>> print f['language'] + +>>> f.fields['language'].choices = [('P', 'Python'), ('J', 'Java')] +>>> print f['language'] + + Add widget=RadioSelect to use that widget with a ChoiceField. >>> class FrameworkForm(Form): ... name = CharField() -- cgit v1.3