mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
newforms: Implemented RadioFieldRenderer.__getitem__(), which allows for index lookup on radio fields
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4238 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
a5d3e0c3ef
commit
247fdc19ad
2 changed files with 23 additions and 0 deletions
|
@ -514,6 +514,25 @@ beatle J P Paul False
|
|||
beatle J G George False
|
||||
beatle J R Ringo False
|
||||
|
||||
A RadioFieldRenderer object also allows index access to individual RadioInput
|
||||
objects.
|
||||
>>> w = RadioSelect()
|
||||
>>> r = w.render('beatle', 'J', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo')))
|
||||
>>> print r[1]
|
||||
<label><input type="radio" name="beatle" value="P" /> Paul</label>
|
||||
>>> print r[0]
|
||||
<label><input checked="checked" type="radio" name="beatle" value="J" /> John</label>
|
||||
>>> r[0].is_checked()
|
||||
True
|
||||
>>> r[1].is_checked()
|
||||
False
|
||||
>>> r[1].name, r[1].value, r[1].choice_value, r[1].choice_label
|
||||
('beatle', u'J', 'P', 'Paul')
|
||||
>>> r[10]
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
IndexError: list index out of range
|
||||
|
||||
# CheckboxSelectMultiple Widget ###############################################
|
||||
|
||||
>>> w = CheckboxSelectMultiple()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue