Added a 'size' option for string input fields that controls the width in characters of the input box.

pull/7/head
Ferry Boender 10 years ago
parent 479aac0e5a
commit 1080b50696
  1. 1
      doc/MANUAL.md
  2. 3
      examples/megacorp_acc/megacorp_acc.json
  3. 9
      src/scriptform.py

@ -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.
### <a name="field_types_integer">Integer</a>

@ -152,7 +152,8 @@
"title": "From IP Address",
"type": "string",
"required": true,
"min_length": 7
"min_length": 7,
"size": 15
},
{
"name": "expire_days",

@ -633,7 +633,7 @@ class WebAppHandler(BaseHTTPRequestHandler):
class FormRender():
field_tpl = {
"string": u'<input {required} type="text" name="{name}" value="{value}" class="{classes}" />',
"string": u'<input {required} type="text" name="{name}" value="{value}" size="{size}" class="{classes}" />',
"number": u'<input {required} type="number" min="{min}" max="{max}" name="{name}" value="{value}" class="{classes}" />',
"integer": u'<input {required} type="number" min="{min}" max="{max}" name="{name}" value="{value}" class="{classes}" />',
"float": u'<input {required} type="number" min="{min}" max="{max}" step="any" name="{name}" value="{value}" class="{classes}" />',
@ -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", '')

Loading…
Cancel
Save