From b84258d91bec8c0505b05f671448c49b79d3c714 Mon Sep 17 00:00:00 2001 From: Ferry Boender Date: Sun, 10 May 2015 13:20:19 +0200 Subject: [PATCH] Allow pre-setting of checkboxes. --- src/scriptform.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/scriptform.py b/src/scriptform.py index 5742ae8..8265334 100755 --- a/src/scriptform.py +++ b/src/scriptform.py @@ -681,7 +681,7 @@ class ScriptFormWebApp(WebAppHandler): "password": u'', "text": u'', "select": u'', - "checkbox": u'', + "checkbox": u'', "radio": u'{3}
', } @@ -723,7 +723,10 @@ class ScriptFormWebApp(WebAppHandler): checked = u'' # Check first radio option input = u''.join(radio_elems) elif field['type'] == 'checkbox': - input = tpl.format(required, field['name'], field_value) + checked = '' + if field['name'] in form_values and form_values[field['name']] == 'on': + checked = 'checked' + input = tpl.format(required, checked, field['name']) elif field['type'] == 'text': rows = field.get('rows', 5) cols = field.get('cols', 80)