Commits

Ralph Bean committed ed16f9a

Modifications and test for RadioButtonTable.

  • Participants
  • Parent commits cf51419

Comments (0)

Files changed (3)

tests/test_widget.py

 
 class TestRadioButtonTable(WidgetTest):
     widget = twb.RadioButtonTable
-    expected = """<TODO>How should this actually work?</TODO>"""
-
+    attrs = {
+        'options': (('a','1'), ('b', '2'), ('c', '3')),
+        'id': 'something',
+    }
+    expected = """<table id="something">
+    <tbody>
+    <tr>
+        <td>
+            <label for="something:0" class="radio">
+            <input type="radio" name="something" value="a" id="something:0">
+            1</label>
+        </td>
+    </tr><tr>
+        <td>
+            <label for="something:1" class="radio">
+            <input type="radio" name="something" value="b" id="something:1">
+            2</label>
+        </td>
+    </tr><tr>
+        <td>
+            <label for="something:2" class="radio">
+            <input type="radio" name="something" value="c" id="something:2">
+            3</label>
+        </td>
+    </tr>
+    </tbody>
+</table>"""
 
 class TestRowLayout(WidgetTest):
     widget = twb.RowLayout

tw2/bootstrap/templates/selection_table.mak

+<%namespace name="tw" module="tw2.core.mako_util"/>\
+<table ${tw.attrs(attrs=w.attrs)}>
+    <tbody>
+   % for row in w.options_rows:
+    <tr>
+       % for attrs, desc in row:
+        <td>
+            <label class="${attrs['type']}" for="${attrs['id']}">
+            <input ${tw.attrs(attrs=attrs)} />
+            ${desc}</label>
+        </td>
+       % endfor
+       % for j in xrange(w.cols - len(row)):
+        <td/>
+       % endfor
+    </tr>
+   % endfor
+    </tbody>
+</table>

tw2/bootstrap/widgets.py

 
 
 class RadioButtonTable(Bootstrap, twf.RadioButtonTable):
-    pass
+    template = "tw2.bootstrap.templates.selection_table"
 
 
 class RowLayout(Bootstrap, twf.RowLayout):