From 386af020a2eefd0b99fdb32ecf64082c1de23242 Mon Sep 17 00:00:00 2001 From: Ferry Boender Date: Mon, 29 Jun 2015 08:25:43 +0200 Subject: [PATCH] Added abilitity to add custom CSS classes to field definitions. --- doc/MANUAL.md | 3 +++ examples/customize/customize.json | 3 ++- src/webapp.py | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/MANUAL.md b/doc/MANUAL.md index af42cbb..4bdeb2b 100644 --- a/doc/MANUAL.md +++ b/doc/MANUAL.md @@ -183,6 +183,9 @@ Structurally, they are made up of the following elements: - **`style`**: A string of inline CSS which will be applied to the field. **Optional**, **String**. + - **`classes`**: A string of optional CSS classes to add to this field. + **Optional**, **String**. + - **`...`**: Other options, which depend on the type of field. For more information, see [Field types](#field_types). **Optional**. diff --git a/examples/customize/customize.json b/examples/customize/customize.json index 4dfeffc..240487d 100644 --- a/examples/customize/customize.json +++ b/examples/customize/customize.json @@ -12,7 +12,8 @@ "name": "background", "title": "Different background color", "type": "string", - "style": "background-color: #C0FFC0;" + "style": "background-color: #C0FFC0;", + "classes": "foo bar" } ] } diff --git a/src/webapp.py b/src/webapp.py index d1371df..2342561 100644 --- a/src/webapp.py +++ b/src/webapp.py @@ -373,6 +373,8 @@ class ScriptFormWebApp(WebAppHandler): if field.get('required', None): params['classes'].append('required') + params['classes'].extend(field.get('classes', '').split()) + params["style"] = field.get("style", "") # Get field-specific parameters