Changeset 4238
- Timestamp:
- 12/26/06 16:56:53 (2 years ago)
- Files:
-
- django/trunk/django/newforms/widgets.py (modified) (1 diff)
- django/trunk/tests/regressiontests/forms/tests.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/newforms/widgets.py
r4235 r4238 190 190 yield RadioInput(self.name, self.value, self.attrs.copy(), choice, i) 191 191 192 def __getitem__(self, idx): 193 choice = self.choices[idx] # Let the IndexError propogate 194 return RadioInput(self.name, self.value, self.attrs.copy(), choice, idx) 195 192 196 def __unicode__(self): 193 197 "Outputs a <ul> for this set of radio fields." django/trunk/tests/regressiontests/forms/tests.py
r4236 r4238 514 514 beatle J G George False 515 515 beatle J R Ringo False 516 517 A RadioFieldRenderer object also allows index access to individual RadioInput 518 objects. 519 >>> w = RadioSelect() 520 >>> r = w.render('beatle', 'J', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo'))) 521 >>> print r[1] 522 <label><input type="radio" name="beatle" value="P" /> Paul</label> 523 >>> print r[0] 524 <label><input checked="checked" type="radio" name="beatle" value="J" /> John</label> 525 >>> r[0].is_checked() 526 True 527 >>> r[1].is_checked() 528 False 529 >>> r[1].name, r[1].value, r[1].choice_value, r[1].choice_label 530 ('beatle', u'J', 'P', 'Paul') 531 >>> r[10] 532 Traceback (most recent call last): 533 ... 534 IndexError: list index out of range 516 535 517 536 # CheckboxSelectMultiple Widget ###############################################
