diff options
| author | Gary Wilson Jr <gary.wilson@gmail.com> | 2007-11-26 02:39:48 +0000 |
|---|---|---|
| committer | Gary Wilson Jr <gary.wilson@gmail.com> | 2007-11-26 02:39:48 +0000 |
| commit | f110da91dbfa2c9db7e6ef2082b4eb28a7741737 (patch) | |
| tree | da9d1427d81ccd8254aafb067b423cf983dc5e9d /tests | |
| parent | 183a457f5a149d7a732a5dd46c7d3f1b77f3a127 (diff) | |
Fixed #5993 -- Made `RadioSelect` easier to subclass by giving it a default `renderer` as a class attribute.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6717 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/forms/widgets.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/widgets.py b/tests/regressiontests/forms/widgets.py index cb1d084631..81254a149e 100644 --- a/tests/regressiontests/forms/widgets.py +++ b/tests/regressiontests/forms/widgets.py @@ -663,6 +663,16 @@ You can create your own custom renderers for RadioSelect to use. <label><input checked="checked" type="radio" name="beatle" value="G" /> George</label><br /> <label><input type="radio" name="beatle" value="R" /> Ringo</label> +Or you can use custom RadioSelect fields that use your custom renderer. +>>> class CustomRadioSelect(RadioSelect): +... renderer = MyRenderer +>>> w = CustomRadioSelect() +>>> print w.render('beatle', 'G', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo'))) +<label><input type="radio" name="beatle" value="J" /> John</label><br /> +<label><input type="radio" name="beatle" value="P" /> Paul</label><br /> +<label><input checked="checked" type="radio" name="beatle" value="G" /> George</label><br /> +<label><input type="radio" name="beatle" value="R" /> Ringo</label> + A RadioFieldRenderer object also allows index access to individual RadioInput objects. >>> w = RadioSelect() |
