diff options
author | Alexander Sulfrian <alex@spline.inf.fu-berlin.de> | 2014-11-18 05:51:18 +0100 |
---|---|---|
committer | Alexander Sulfrian <alex@spline.inf.fu-berlin.de> | 2014-11-19 02:15:56 +0100 |
commit | 7936b83766edbf70321851bc02c96fae620a9e88 (patch) | |
tree | 4d7b83f560e035a840d5e2d8d9c0c8ad9755f604 | |
parent | b51620eb9502997a2f55a485e55e0e73f6450449 (diff) | |
download | padlite-teams-7936b83766edbf70321851bc02c96fae620a9e88.tar.gz padlite-teams-7936b83766edbf70321851bc02c96fae620a9e88.tar.bz2 padlite-teams-7936b83766edbf70321851bc02c96fae620a9e88.zip |
widgets: add TextArea, that caches rows/cols until rendering
-rw-r--r-- | forms.py | 5 | ||||
-rw-r--r-- | widgets.py | 12 |
2 files changed, 16 insertions, 1 deletions
@@ -3,6 +3,7 @@ from utils import Unique from models import Group from wtfpeewee.orm import model_form from flask.ext.wtf import Form +from widgets import TextArea CreateGroup = model_form(Group, base_class=Form, exclude=['api_id'], field_args={ @@ -13,7 +14,9 @@ CreateGroup = model_form(Group, base_class=Form, exclude=['api_id'], field_args= validators.Regexp('^[a-zA-Z1-9]', message=u'Group name should not ' 'start with a special character.'), Unique(Group, Group.name, message=u'A group with this name ' - 'already exists.')]}}) + 'already exists.')] + }, + 'description': {'widget': TextArea(rows=7)}}) class DeleteGroup(Form): diff --git a/widgets.py b/widgets.py new file mode 100644 index 0000000..77f3650 --- /dev/null +++ b/widgets.py @@ -0,0 +1,12 @@ +import wtforms.widgets.core + + +class TextArea(wtforms.widgets.core.TextArea): + def __init__(self, **kwargs): + self.kwargs = kwargs + + def __call__(self, field, **kwargs): + for arg in self.kwargs: + if arg not in kwargs: + kwargs[arg] = self.kwargs[arg] + return super(TextArea, self).__call__(field, **kwargs) |