How to use the wtforms.Form function in WTForms

To help you get started, we’ve selected a few WTForms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kvesteri / wtforms-alchemy / tests / test_weekdays_field.py View on Github external
def init_form(self, **kwargs):
        class TestForm(Form):
            test_field = WeekDaysField(**kwargs)
        return TestForm
github kvesteri / wtforms-components / tests / fields / test_color_field.py View on Github external
def init_form(self, **kwargs):
        class TestForm(Form):
            color = ColorField(**kwargs)

        self.form_class = TestForm
        return self.form_class
github DOAJ / doaj / portality / formcontext / forms.py View on Github external
class PublicSuggester(Form):
    """ Suggester's contact details to be provided via the public application form """

    suggester_name = StringField('Your name',
        [validators.DataRequired()]
    )
    suggester_email = StringField('Your email address',
        [validators.DataRequired(), validators.Email(message='Invalid email address.')]
    )
    suggester_email_confirm = StringField('Confirm your email address',
        [validators.DataRequired(), validators.Email(message='Invalid email address.'), validators.EqualTo('suggester_email', EMAIL_CONFIRM_ERROR)]
    )


class AdminSuggester(Form):
    """ Suggester's contact details as presented to administrators/editors in the DOAJ workflow"""

    suggester_name = StringField("Name",
        [validators.DataRequired()]
    )
    suggester_email = StringField("Email address",
        [validators.DataRequired(), validators.Email(message='Invalid email address.')]
    )
    suggester_email_confirm = StringField("Confirm email address",
        [validators.DataRequired(), validators.Email(message='Invalid email address.'), validators.EqualTo('suggester_email', EMAIL_CONFIRM_ERROR)]
    )


class Note(Form):
    """ Note form for use in admin area - recommended to be included by the composing form as a FormField, so it can be
        represented as a multi-field.  Use Notes to achieve this """
github keelii / snote / app / user / form.py View on Github external
email = TextField('Email', validators=[
        Email(),
        Required(),
        Length(min=5, max=40)
    ])
    nick_name = TextField('Nickname', validators=[
        Length(min=3, max=25),
    ])
    password = PasswordField('Password', validators=[
        Required(),
        Length(min=6, max=20),
        EqualTo('confirm', message='Passwords must match')
    ])
    confirm = PasswordField('Confirm password')

class LoginForm(Form):
    email = TextField('Email', validators=[
        Email(),
        Required(),
        Length(min=5, max=40)
    ])
    password = PasswordField('Password', validators=[
        Required(),
        Length(min=6, max=20)
    ])
    remember = BooleanField('remember')
github Pylons / pyramid_blogr / pyramid_blogr / forms.py View on Github external
from wtforms import Form, StringField, TextAreaField, validators
from wtforms import IntegerField, PasswordField
from wtforms.widgets import HiddenInput

strip_filter = lambda x: x.strip() if x else None

class BlogCreateForm(Form):
    title = StringField('Title', [validators.Length(min=1, max=255)],
                        filters=[strip_filter])
    body = TextAreaField('Contents', [validators.Length(min=1)],
                         filters=[strip_filter])

class BlogUpdateForm(BlogCreateForm):
    id = IntegerField(widget=HiddenInput())


class RegistrationForm(Form):
    username = StringField('Username', [validators.Length(min=1, max=255)],
                           filters=[strip_filter])
    password = PasswordField('Password', [validators.Length(min=3)])
github alfg / screenchop / screenchop / forms.py View on Github external
class LoginForm(Form):
    username = TextField('Username')
    password = PasswordField('Password')
    
class AccountForm(Form):
    newpass = PasswordField('New Password', [
        validators.Required(message='Password required'),
        validators.EqualTo('confirm', message='Passwords must match')
    ])
    confirm = PasswordField('Repeat Password')
    currentpass = PasswordField('Current Password', [
        validators.Required(message='Current password required')
    ])

class ProfileForm(Form):
    description = TextAreaField('Profile Description', [
        validators.Length(max=300, message='Max 300 characters'),
        ])

class EditPost(Form):
    caption = TextAreaField('Caption', [
        validators.Length(max=100, message='Max 100 characters')
            ])
    tags = TagListField('Tags')

class ReportPost(Form):
    reason = TextAreaField('Reason', [
        validators.Length(max=1000, message='Max 1000 characters')
            ])

class AddFromURLForm(Form):
github hplgit / parampool / doc / src / pp / src-pp / .reference_files / compute_motion_and_forces_with_pool_pool_definition_api_with_separate_subpools_model.py View on Github external
import wtforms as wtf
from parampool.html5.flask.fields import HTML5FloatField, FloatRangeField, IntegerRangeField
import flask.ext.wtf.html5 as html5

class MotionAndForcesWithPool(wtf.Form):

    Initial_velocity       = wtf.TextField(
        label=u'Initial velocity',
        description=u'Initial velocity',
        default='5.0',
        validators=[wtf.validators.InputRequired()])

    Initial_angle          = FloatRangeField(
        label=u'Initial angle',
        description=u'Initial angle',
        default=45,
        onchange="showValue(this.value)",
        min=0, max=90, step=0,
        validators=[wtf.validators.InputRequired(),
                    wtf.validators.NumberRange(0, 90)])
github livro-aberto / BookCloud / application / views.py View on Github external
# import special tools for this platform
from tools import window, rst2html, Command, get_git, load_file,\
    write_file, get_merging, get_requests, get_merge_pendencies,\
    config_repo, is_dirty, get_log, get_log_diff, last_modified

config_path = 'conf'

bookcloud = Blueprint('bookcloud', __name__, template_folder='templates')

babel = Babel(app)

import pprint
pp = pprint.PrettyPrinter(indent=4).pprint

class IdentifierForm(Form):
    name = StringField('Identifier', [
        validators.Length(min=4, max=25),
        validators.Regexp('^[\w-]+$', message="Identifiers must contain only a-zA-Z0-9_-"),
    ])

class MessageForm(Form):
    message = StringField('Message', [
        validators.Length(min=4, max=60),
        validators.Regexp('^[\w ,.?!-]+$',
                          message="Messages must contain only a-zA-Z0-9_-,.!? and space"),
    ])

class CommentSearchForm(Form):
    search = StringField('Search', [ validators.Length(min=3, max=60)])

def select_multi_checkbox(field, ul_class='', **kwargs):
github burness / arxiv_tools / flask / forms.py View on Github external
# pythonspot.com
from flask import Flask, render_template, flash, request
from wtforms import Form, TextField, TextAreaField, validators, StringField, SubmitField
import fcntl

USER_INFO_FILE = './static/user_info.csv'
# App config.
DEBUG = True
app = Flask(__name__)
app.config.from_object(__name__)
app.config['SECRET_KEY'] = '213949948595995'
 
class ReusableForm(Form):
    name = TextField('Name:', validators=[validators.required()])
    email = TextField('Email:', validators=[validators.required(), validators.Length(min=6, max=35)])
    subject = TextField('Subject:', validators=[validators.required()])
 

def write_file(**user_info):
    # write the file with amend mode
    with open(USER_INFO_FILE,'a') as fwrite:
        # file_no = fwrite.fileno()
        # add the lock of the file when you write the content to the file
        # fcntl.lockf(file_no,fcntl.LOCK_EX|fcntl.LOCK_NB)
        temp_line = user_info['name'] +',' +user_info['subject']+',' + user_info['email']+'\n'
        fwrite.write(temp_line)


@app.route("/", methods=['GET', 'POST'])
github korymath / talk-generator / talkgenerator / server / hello.py View on Github external
from flask import Flask, render_template, flash, request, send_from_directory
from flask_sslify import SSLify
from wtforms import Form, TextField, validators

# App config.
DEBUG = True
app = Flask(__name__)
sslify = SSLify(app)

app.config.from_object(__name__)
app.config["SECRET_KEY"] = "101710171017"
app.config["OUTPUT_FOLDER"] = "output"


class ReusableForm(Form):
    talk_topic = TextField("Topic: ", validators=[validators.required()])


@app.route("/output/", methods=["GET", "POST"])
def download(filename):
    outputs = os.path.join(app.root_path, app.config["OUTPUT_FOLDER"])
    return send_from_directory(directory=outputs, filename=filename)


@app.route("/", methods=["GET", "POST"])
def hello():
    form = ReusableForm(request.form)
    print("Errors: {}".format(form.errors))

    if request.method == "POST":
        talk_topic = request.form["talk_topic"]