Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# encoding: utf-8 

2from . import * 

3 

4def radio( 

5 optionText="", 

6 optionNumber=1, 

7 htmlId=False, 

8 inlineHelpText=False, 

9 blockHelpText=False, 

10 disabled=False, 

11 checked=False): 

12 """ 

13 *Generate a radio - TBS style* 

14 

15 **Key Arguments** 

16 

17 - ``optionText`` -- the text associated with this checkbox 

18 - ``optionNumber`` -- the order in the option list 

19 - ``htmlId`` -- the html id of the element 

20 - ``inlineHelpText`` -- inline and block level support for help text that appears around form controls 

21 - ``blockHelpText`` -- a longer block of help text that breaks onto a new line and may extend beyond one line 

22 - ``disabled`` -- add the disabled attribute on an input to prevent user input 

23 - ``checked`` -- is the radio button checked by default 

24  

25 

26 **Return** 

27 

28 - ``radio`` -- the radio 

29  

30 """ 

31 if inlineHelpText: 

32 inlineHelpText = """<span class="help-inline">%(inlineHelpText)s</span>""" % locals( 

33 ) 

34 else: 

35 inlineHelpText = "" 

36 

37 if blockHelpText: 

38 blockHelpText = """<span class="help-block">%(blockHelpText)s</span>""" % locals( 

39 ) 

40 else: 

41 blockHelpText = "" 

42 

43 if disabled: 

44 disabled = """disabled""" 

45 disabledId = "disabledId" 

46 else: 

47 disabled = "" 

48 disabledId = "" 

49 

50 if checked is False: 

51 checked = "" 

52 else: 

53 checked = "checked" 

54 

55 if not htmlId: 

56 htmlId = "" 

57 

58 radio = """ 

59 <label class="radio"> 

60 <input type="radio" name="%(htmlId)s" id="%(htmlId)s %(disabledId)s %(htmlId)s" value="%(optionText)s" %(checked)s %(disabled)s> 

61 %(optionText)s 

62 </label>%(inlineHelpText)s%(inlineHelpText)s""" % locals() 

63 

64 return radio