-
Notifications
You must be signed in to change notification settings - Fork 0
/
forms.py
37 lines (20 loc) · 922 Bytes
/
forms.py
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,
SelectField,
ValidationError
)
class PlayerForm(Form):
player_one = SelectField('Player One',
render_kw={'class_': 'form-control form-control-lg'},
choices=[(0, 'Select Symbols'), ('x', "X"), ('o', 'O')])
player_two = SelectField('Player Two',
render_kw={'class_': 'form-control form-control-lg'},
choices=[(0, 'Select Symbols'), ('x', "X"), ('o', 'O')])
def validate_player_one(form, field):
if not field.data:
raise ValidationError("field is required")
if field.data == form.player_two.data:
raise ValidationError("player symbol not unique")
def validate_player_two(form, field):
if not field.data:
raise ValidationError("field is required")