Commits

Ralph Bean committed 145ec2f

Modifications and test for RadioButtonList.

Comments (0)

Files changed (3)

tests/test_widget.py

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

tw2/bootstrap/templates/selection_list.mak

+<%namespace name="tw" module="tw2.core.mako_util"/>\
+<ul ${tw.attrs(attrs=w.attrs)}>
+   % for group, opts in w.grouped_options:
+   % if group:
+    <li>
+    <div class="group_header">${group}</div>
+    <ul>
+   % endif   
+   % for attrs, desc in opts:
+    <li>
+        <label class="${attrs['type']}" for="${attrs['id']}">
+        <input ${tw.attrs(attrs=attrs)}>
+        ${desc}</label>
+    </li>
+   % endfor
+   % if group:
+    </li>
+    </ul>
+   % endif   
+   % endfor
+</ul>

tw2/bootstrap/widgets.py

 
 
 class RadioButtonList(Bootstrap, twf.RadioButtonList):
-    pass
+    template = "tw2.bootstrap.templates.selection_list"
 
 
 class RadioButtonTable(Bootstrap, twf.RadioButtonTable):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.