From 4bcd0e9e43e13176b843c750cd364beff4144abd Mon Sep 17 00:00:00 2001
From: Ferry Boender
Date: Sun, 10 May 2015 14:54:07 +0200
Subject: [PATCH] Better display for checkbox input.
---
src/scriptform.py | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/src/scriptform.py b/src/scriptform.py
index 8265334..6920f42 100755
--- a/src/scriptform.py
+++ b/src/scriptform.py
@@ -69,6 +69,7 @@ html_header = u'''
div.form li.hidden {{ display: none; }}
div.form p.form-field-title {{ margin-bottom: 0px; }}
div.form p.form-field-input {{ margin-top: 0px; }}
+ div.form li.checkbox p.form-field-input {{ float: left; margin-right: 8px; }}
select,
textarea,
input[type=text],
@@ -132,6 +133,19 @@ html_form = u'''
{footer}
'''
+html_field = u'''
+
+ {title}
+ {input} {errors}
+
+'''
+
+html_field_checkbox = u'''
+
+ {input}
{title}
{errors}
+
+'''
+
html_submit_response = u'''
{header}
@@ -753,15 +767,14 @@ class ScriptFormWebApp(WebAppHandler):
if 'hidden' in field and field['hidden']:
classes += 'hidden '
- return (u'''
-
- {title}
- {input} {errors}
-
- '''.format(classes=classes,
- title=field['title'],
- input=input,
- errors=u', '.join(errors)))
+ if field['type'] != 'checkbox':
+ html = html_field
+ else:
+ html = html_field_checkbox
+ return (html.format(classes=classes,
+ title=field['title'],
+ input=input,
+ errors=u', '.join(errors)))
# Make sure the user is allowed to access this form.
form_def = form_config.get_form_def(form_name)