From 563f3cdca5f12b690d820459f80a41c3f91a1c69 Mon Sep 17 00:00:00 2001 From: Ferry Boender Date: Fri, 15 May 2015 09:25:45 +0200 Subject: [PATCH] Move rendering of a form line to the FormRender class. --- src/scriptform.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/scriptform.py b/src/scriptform.py index 96f63e7..76944a9 100755 --- a/src/scriptform.py +++ b/src/scriptform.py @@ -693,6 +693,16 @@ class FormRender(): tpl = self.field_tpl['select'] return tpl.format(name=name, select_elems=''.join(select_elems), classes=classes) + def r_form_line(self, type, title, input, classes, errors): + if type == 'checkbox': + html = html_field_checkbox + else: + html = html_field + + return (html.format(classes=classes, + title=title, + input=input, + errors=u', '.join(errors))) class ScriptFormWebApp(WebAppHandler): """ @@ -829,14 +839,8 @@ class ScriptFormWebApp(WebAppHandler): input = fr.r_field(field['type'], **params) - if field['type'] != 'checkbox': - html = html_field - else: - html = html_field_checkbox - return (html.format(classes=params['classes'], - title=field['title'], - input=input, - errors=u', '.join(errors))) + return fr.r_form_line(field['type'], field['title'], + input, params['classes'], errors) # Make sure the user is allowed to access this form. form_def = form_config.get_form_def(form_name)