Commits

Anonymous committed 7b04c64

Added new renderer for selection fields.

  • Participants
  • Parent commits 58da03f

Comments (0)

Files changed (2)

formbar/renderer.py

         FieldRenderer.__init__(self, field, translate)
         self.template = template_lookup.get_template("dropdown.mako")
 
+class SelectionFieldRenderer(FieldRenderer):
+    """A Renderer to render selection field"""
+
+    def __init__(self, field, translate):
+        FieldRenderer.__init__(self, field, translate)
+        self.template = template_lookup.get_template("selection.mako")
+
 
 class ListFieldRenderer(FieldRenderer):
     """A Renderer to render selection list"""

formbar/templates/selection.mako

+% if field.is_readonly():
+  <div class="readonlyfield">
+    ${field.get_value() or "&nbsp;"}
+  </div>
+% else:
+  <select name="${field.name}" size="5" multiple>
+    % for option in field.get_options():
+      <option value="${option[1]}">${option[0]}</option>
+    % endfor
+  </select>
+% endif