forked from flatplanet/flasker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webforms.py
86 lines (75 loc) · 2.44 KB
/
webforms.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, PasswordField, BooleanField, ValidationError, TextAreaField
from wtforms.validators import DataRequired, EqualTo, Length
from wtforms.widgets import TextArea
from flask_ckeditor import CKEditorField
from flask_wtf.file import FileField
# Create A Search Form
class SearchForm(FlaskForm):
searched = StringField("Searched", validators=[DataRequired()])
submit = SubmitField("Submit")
# Create Login Form
class LoginForm(FlaskForm):
username = StringField("Username", validators=[DataRequired()])
password = PasswordField("Password", validators=[DataRequired()])
submit = SubmitField("Submit")
# Create a Posts Form
class PostForm(FlaskForm):
title = StringField("Title", validators=[DataRequired()])
#content = StringField("Content", validators=[DataRequired()], widget=TextArea())
content = CKEditorField('Content', validators=[DataRequired()])
#author = StringField("Author")
slug = StringField("Slug", validators=[DataRequired()])
submit = SubmitField("Submit")
# Create a Form Class
class UserForm(FlaskForm):
name = StringField("Name", validators=[DataRequired()])
username = StringField("Username", validators=[DataRequired()])
email = StringField("Email", validators=[DataRequired()])
favorite_color = StringField("Favorite Color")
about_author = TextAreaField("About Author")
password_hash = PasswordField('Password', validators=[DataRequired(), EqualTo('password_hash2', message='Passwords Must Match!')])
password_hash2 = PasswordField('Confirm Password', validators=[DataRequired()])
profile_pic = FileField("Profile Pic")
submit = SubmitField("Submit")
class PasswordForm(FlaskForm):
email = StringField("What's Your Email", validators=[DataRequired()])
password_hash = PasswordField("What's Your Password", validators=[DataRequired()])
submit = SubmitField("Submit")
# Create a Form Class
class NamerForm(FlaskForm):
name = StringField("What's Your Name", validators=[DataRequired()])
submit = SubmitField("Submit")
# BooleanField
# DateField
# DateTimeField
# DecimalField
# FileField
# HiddenField
# MultipleField
# FieldList
# FloatField
# FormField
# IntegerField
# PasswordField
# RadioField
# SelectField
# SelectMultipleField
# SubmitField
# StringField
# TextAreaField
## Validators
# DataRequired
# Email
# EqualTo
# InputRequired
# IPAddress
# Length
# MacAddress
# NumberRange
# Optional
# Regexp
# URL
# UUID
# AnyOf
# NoneOf