forked from Akagi201/learning-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepl.py
More file actions
34 lines (24 loc) · 839 Bytes
/
Copy pathrepl.py
File metadata and controls
34 lines (24 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from wtforms import Form, StringField, validators
class UsernameForm(Form):
username = StringField('Username', [validators.Length(min=5)], default=u'test')
form = UsernameForm()
print(form['username'])
print(form.username)
print(form.username.data)
print(form.validate())
print(form.errors)
form2 = UsernameForm(username=u'Robert')
print(form2.data)
print(form2.validate())
print(form2.errors)
class ChangeEmailForm(Form):
email = StringField('Email', [
validators.Length(min=6, message=u'Little short for an email address?'),
validators.Email(message=u'That\'s not a valid email address.')
])
class SimpleForm(Form):
content = StringField('content')
form = SimpleForm(content='foobar')
print(str(form.content))
print(unicode(form.content))
print(form.content(style="width: 200px;", class_="bar"))