Skip to content

Commit

Permalink
Added FormField example to sample application.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbr committed Feb 15, 2014
1 parent 3e19778 commit 8fcb55d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion sample_application/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
from flask_appconfig import AppConfig
from flask_wtf import Form, RecaptchaField
from wtforms import TextField, HiddenField, ValidationError, RadioField,\
BooleanField, SubmitField
BooleanField, SubmitField, IntegerField, FormField, validators
from wtforms.validators import Required


# straight from the wtforms docs:
class TelephoneForm(Form):
country_code = IntegerField('Country Code', [validators.required()])
area_code = IntegerField('Area Code/Exchange', [validators.required()])
number = TextField('Number')


class ExampleForm(Form):
field1 = TextField('First Field', description='This is field one.')
field2 = TextField('Second Field', description='This is field two.',
Expand All @@ -21,6 +28,13 @@ class ExampleForm(Form):
])
checkbox_field = BooleanField('This is a checkbox',
description='Checkboxes can be tricky.')

# subforms
mobile_phone = FormField(TelephoneForm)

# you can change the label as well
office_phone = FormField(TelephoneForm, label='Your office phone')

submit_button = SubmitField('Submit Form')

def validate_hidden_field(form, field):
Expand Down

0 comments on commit 8fcb55d

Please sign in to comment.