-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforms.py
19 lines (16 loc) · 1.01 KB
/
forms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from flask_wtf import FlaskForm
from wtforms import StringField, IntegerField, BooleanField, SelectField
from wtforms.validators import URL, Optional, InputRequired, Length, NumberRange
class AddPetForm(FlaskForm):
name = StringField('Pet Name', validators = [InputRequired('Name cant be empty')])
species = SelectField('Species', choices = [('cat', 'Cat'), ("dog", "Dog"), ('bunny', 'Bunny')])
photo = StringField('Photo URL', validators = [Optional(), URL()])
age = IntegerField('Age', validators = [NumberRange(min=0, max=30)])
notes = StringField('Notes')
available = BooleanField('available?')
class EditPetForm(FlaskForm):
name = StringField('Pet Name', validators = [InputRequired('Name cant be empty')])
species = SelectField('Species', choices = [('cat', 'Cat'), ("dog", "Dog"), ('bunny', 'Bunny')])
photo_url = StringField("Photo URL", validators=[Optional(), URL()])
notes = StringField("Notes", validators=[Optional(), Length(min=10)])
available = BooleanField("Available?")