Commits

Torsten Irländer  committed 8ec57fe

Added a Timefield Renderer

  • Participants
  • Parent commits 1be06df

Comments (0)

Files changed (2)

File formbar/renderer.py

             return DateFieldRenderer(field, translate)
         elif dtype == "file":
             return FileFieldRenderer(field, translate)
+        elif dtype == "time":
+            return TimeFieldRenderer(field, translate)
     return TextFieldRenderer(field, translate)
 
 
         FieldRenderer.__init__(self, field, translate)
         self.template = template_lookup.get_template("textfield.mako")
 
+class TimeFieldRenderer(FieldRenderer):
+    """A Renderer to render simple fa_field elements"""
+
+    def __init__(self, field, translate):
+        FieldRenderer.__init__(self, field, translate)
+        self.template = template_lookup.get_template("timefield.mako")
+
 
 class FileFieldRenderer(FieldRenderer):
     """A Renderer to render simple fa_field elements"""

File formbar/templates/timefield.mako

+% if field.is_readonly():
+  <div class="readonlyfield" name="${field.name}">
+    ${field.get_value("")}
+  </div>
+% else:
+  <input id="${field.id}" type="text" name="${field.name}" value="${field.get_value()}" placeholder="HH:MM:SS"/>
+% endif
+<script>
+$('#${field.id}').keyup(function() {
+    /* TODO: Check wo to improve to prevent the user to insert only
+    allowed chars. Now the char can be entered but it gets replaced
+    imediately if it does not match the allowed char. (None) <2013-08-25
+    21:11> */
+    this.value = this.value.replace(/[^0-9:]/g, '');
+});
+
+</script>