diff --git a/doc/MANUAL.md b/doc/MANUAL.md
index 295fcc5..789940c 100644
--- a/doc/MANUAL.md
+++ b/doc/MANUAL.md
@@ -246,6 +246,7 @@ The `string` field type supports the following additional options:
- **`minlen`**: The minimum allowed length for the field.
- **`maxlen`**: The maximum allowed length for the field.
+- **`size`**: The size (in characters) of the input field.
### Integer
diff --git a/examples/megacorp_acc/megacorp_acc.json b/examples/megacorp_acc/megacorp_acc.json
index 419c67e..26d0d9d 100644
--- a/examples/megacorp_acc/megacorp_acc.json
+++ b/examples/megacorp_acc/megacorp_acc.json
@@ -152,7 +152,8 @@
"title": "From IP Address",
"type": "string",
"required": true,
- "min_length": 7
+ "min_length": 7,
+ "size": 15
},
{
"name": "expire_days",
diff --git a/src/scriptform.py b/src/scriptform.py
index c1a169c..4cf26d7 100755
--- a/src/scriptform.py
+++ b/src/scriptform.py
@@ -633,7 +633,7 @@ class WebAppHandler(BaseHTTPRequestHandler):
class FormRender():
field_tpl = {
- "string": u'',
+ "string": u'',
"number": u'',
"integer": u'',
"float": u'',
@@ -676,9 +676,9 @@ class FormRender():
method = getattr(self, method_name, None)
return method(**params)
- def r_field_string(self, name, value, required=False, classes=[]):
+ def r_field_string(self, name, value, size=50, required=False, classes=[]):
tpl = self.field_tpl['string']
- return tpl.format(name=name, value=value, required=required, classes=classes)
+ return tpl.format(name=name, value=value, size=size, required=required, classes=classes)
def r_field_number(self, name, value, min=None, max=None, required=False, classes=[]):
tpl = self.field_tpl['number']
@@ -855,6 +855,9 @@ class ScriptFormWebApp(WebAppHandler):
if field['type'] not in ('radio', 'checkbox', 'select'):
params['required'] = field.get('required', False),
+ if field['type'] in ('string'):
+ params['size'] = field.get('size', '')
+
if field['type'] in ('number', 'integer', 'float', 'password'):
params['min'] = field.get("min", '')