| 34 | | res="<tr><td valign=top>%s</td>"%field.label |
|---|
| 35 | | if field.typ=='text': |
|---|
| 36 | | res+='<td><input name="%s" type=text value="%s" size=%s></td>'%(field.name, field.currentValue, field.size) |
|---|
| 37 | | elif field.typ=='forced': |
|---|
| 38 | | res+='<td><input name="%s" type=hidden value="%s">%s</td>'%(field.name, field.currentValue, field.currentValue) |
|---|
| 39 | | elif field.typ=='password': |
|---|
| 40 | | res+='<td><input name="%s" type=password value="%s"></td>'%(field.name, field.currentValue) |
|---|
| 41 | | elif field.typ=='select': |
|---|
| 42 | | res+='<td><select name="%s">'%field.name |
|---|
| | 50 | |
|---|
| | 51 | res = ["<tr>", |
|---|
| | 52 | "<td valign='top'>%s</td>" % field.label] |
|---|
| | 53 | |
|---|
| | 54 | if field.typ == 'text': |
|---|
| | 55 | res.append('<td><input name=%s type="text" value=%s size=%s /></td>' |
|---|
| | 56 | % (q(field.name), q(field.currentValue), q(field.size))) |
|---|
| | 57 | elif field.typ == 'forced': |
|---|
| | 58 | res.append('<td><input name=%s type="hidden" value=%s />%s</td>' |
|---|
| | 59 | % (q(field.name), q(field.currentValue), field.currentValue)) |
|---|
| | 60 | elif field.typ == 'password': |
|---|
| | 61 | res.append('<td><input name=%s type="password" value=%s /></td>' |
|---|
| | 62 | % (q(field.name), q(field.currentValue))) |
|---|
| | 63 | elif field.typ == 'select': |
|---|
| | 64 | res.append('<td><select name=%s>' % q(field.name)) |
|---|
| 44 | | if type(option)==type(()): |
|---|
| 45 | | optionId, optionLabel=option |
|---|
| 46 | | if optionId==field.currentValue or str(optionId)==field.currentValue: res+="<option selected value=%s>%s</option>"%(optionId, optionLabel) |
|---|
| 47 | | else: res+="<option value=%s>%s</option>"%(optionId, optionLabel) |
|---|
| | 66 | if isinstance(option, tuple): |
|---|
| | 67 | id, option = option |
|---|
| | 68 | sel = selected(field.currentValue in (id, str(id))) |
|---|
| | 69 | value = " value=%s" % q(id) |
|---|
| 49 | | if option==field.currentValue: res+="<option selected>%s</option>"%option |
|---|
| 50 | | else: res+="<option>%s</option>"%option |
|---|
| 51 | | res+='</select></td>' |
|---|
| 52 | | elif field.typ=='textarea': |
|---|
| 53 | | # Size is colsxrows |
|---|
| 54 | | if field.size==15: size="15x15" |
|---|
| 55 | | else: size=field.size |
|---|
| 56 | | cols, rows=size.split('x') |
|---|
| 57 | | res+='<td><textarea name="%s" rows="%s" cols="%s">%s</textarea></td>'%(field.name, rows, cols, field.currentValue) |
|---|
| 58 | | elif field.typ=='submit': |
|---|
| 59 | | res+='<td><input type=submit value="%s"></td>'%field.name |
|---|
| 60 | | elif field.typ=='hidden': |
|---|
| 61 | | if type(field.currentValue)==type([]): currentValue=field.currentValue |
|---|
| 62 | | else: currentValue=[field.currentValue] |
|---|
| 63 | | res="" |
|---|
| 64 | | for value in currentValue: |
|---|
| 65 | | res+='<input name="%s" type=hidden value="%s">'%(field.name, value) |
|---|
| 66 | | return res |
|---|
| 67 | | elif field.typ=='checkbox' or field.typ=='radio': |
|---|
| 68 | | res+='<td>' |
|---|
| 69 | | # print "##### currentValue:", field.currentValue # TBC |
|---|
| | 71 | sel = selected(option == field.currentValue) |
|---|
| | 72 | value = "" |
|---|
| | 73 | res.append(" <option%s%s>%s</option>" % (sel, value, option)) |
|---|
| | 74 | res.append('</select></td>') |
|---|
| | 75 | elif field.typ == 'textarea': |
|---|
| | 76 | # Size is cols x rows |
|---|
| | 77 | if field.size == 15: |
|---|
| | 78 | size = "15x15" |
|---|
| | 79 | else: |
|---|
| | 80 | size = field.size |
|---|
| | 81 | cols, rows = size.split('x') |
|---|
| | 82 | res.append('<td><textarea name=%s rows="%s" cols="%s">%s</textarea></td>' |
|---|
| | 83 | % (q(field.name), rows, cols, field.currentValue)) |
|---|
| | 84 | elif field.typ == 'submit': |
|---|
| | 85 | res.append('<td><input type="submit" value=%s /></td>' % q(field.name)) |
|---|
| | 86 | elif field.typ == 'hidden': |
|---|
| | 87 | if isinstance(field.currentValue, list): |
|---|
| | 88 | vals = field.currentValue |
|---|
| | 89 | else: |
|---|
| | 90 | vals = [field.currentValue] |
|---|
| | 91 | i = '<input name=%s type="hidden" value=%%s />' % q(field.name) |
|---|
| | 92 | return [i % q(v) for v in vals] |
|---|
| | 93 | elif field.typ in ('checkbox', 'radio'): |
|---|
| | 94 | res.append('<td>') |
|---|
| 71 | | if type(option)==type(()): optionValue, optionLabel=option |
|---|
| 72 | | else: optionValue, optionLabel=option, option |
|---|
| 73 | | res+='<input type="%s" name="%s" value="%s"'%(field.typ, field.name, optionValue) |
|---|
| 74 | | if type(field.currentValue)==type([]): |
|---|
| 75 | | if optionValue in field.currentValue: res+=' checked' |
|---|
| | 96 | if isinstance(option, tuple): |
|---|
| | 97 | val, label = option |
|---|
| 77 | | if optionValue==field.currentValue: res+=' checked' |
|---|
| 78 | | res+='> %s<br>'%optionLabel |
|---|
| 79 | | res+='</td>' |
|---|
| | 99 | val, label = option, option |
|---|
| | 100 | |
|---|
| | 101 | if isinstance(field.currentValue, list): |
|---|
| | 102 | c = checked(val in field.currentValue) |
|---|
| | 103 | else: |
|---|
| | 104 | c = checked(val == field.currentValue) |
|---|
| | 105 | |
|---|
| | 106 | res.append('<input type="%s" name=%s value=%s %s /> %s<br />' |
|---|
| | 107 | % (field.typ, q(field.name), q(val), c, label)) |
|---|
| | 108 | res.append('</td>') |
|---|
| | 109 | |
|---|
| 86 | | if type(field.currentValue)==type([]): currentValue=field.currentValue |
|---|
| 87 | | else: currentValue=[field.currentValue] |
|---|
| 88 | | res="" |
|---|
| 89 | | for value in currentValue: |
|---|
| 90 | | res+='<input name="%s" type=hidden value="%s">'%(field.name, value) |
|---|
| 91 | | return res |
|---|
| | 119 | if isinstance(field.currentValue, list): |
|---|
| | 120 | currentValue = field.currentValue |
|---|
| | 121 | else: |
|---|
| | 122 | currentValue = [field.currentValue] |
|---|
| | 123 | return "\n".join(['<input name=%s type="hidden" value=%s />' % |
|---|
| | 124 | (q(field.name), q(value)) for value in currentValue]) |
|---|
| | 125 | |
|---|