Skip to content

Instantly share code, notes, and snippets.

Created January 29, 2013 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4667323 to your computer and use it in GitHub Desktop.
Save anonymous/4667323 to your computer and use it in GitHub Desktop.
Example RadioField Form.
from flask import Flask, render_template
from flask.ext.wtf import Form, RadioField
SECRET_KEY = 'development'
app = Flask(__name__)
app.config.from_object(__name__)
class SimpleForm(Form):
example = RadioField('Label', choices=[('value','description'),('value_two','whatever')])
@app.route('/',methods=['post','get'])
def hello_world():
form = SimpleForm()
if form.validate_on_submit():
print form.example.data
else:
print form.errors
return render_template('example.html',form=form)
if __name__ == '__main__':
app.run(debug=True)
#<form method="post">
# {{ form.hidden_tag() }}
# {% for subfield in form.example %}
# <tr>
# <td>{{ subfield }}</td>
# <td>{{ subfield.label }}</td>
# </tr>
# {% endfor %}
# <input type="submit">
#</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment