Skip to content

Instantly share code, notes, and snippets.

@doobeh
Created January 30, 2013 15:35
Show Gist options
  • Select an option

  • Save doobeh/4674064 to your computer and use it in GitHub Desktop.

Select an option

Save doobeh/4674064 to your computer and use it in GitHub Desktop.
<form method="post">
{{ form.hidden_tag() }}
{{ form.images }}
<input type="submit">
</form>
from flask import Flask, render_template
from flask.ext.wtf import Form, widgets, SelectMultipleField, RadioField
SECRET_KEY = 'development'
app = Flask(__name__)
app.config.from_object(__name__)
class DatabaseForm(Form):
listOfRows = [(1, u'FromFlask', u'file1.ext', u"['file2.ext']", u'WCP', u'WR_HS', u'email@hotmail.com', u'nothing happens', u'2013-01-3009:15:18.628922', u'None'), (2, u'FromFlask', u'file1.ext', u"['file2.ext']", u'WCP', u'WR_HS', u'email@hotmail.com', u'nothing happens', u'2013-01-3009:15:29.963847', u'None'), (3, u'FromFlask', u'file1.ext', u"['file2.ext']", u'WCP', u'WR_HS', u'email@windriver.com', u'nothing happens', u'2013-01-3009:21:16.275987', u'None'), (4, u'Cody', u'file1.ext', u"['inp_test.ext']", u'WCA', u'WR_HS', u'email@windriver.com', u'nothing happens', u'2013-01-3009:34:03.196901', u'None')]
rows = [(x[0], x[2]) for x in listOfRows]
images = RadioField('images', choices = rows)
@app.route('/',methods=['post','get'])
def hello_world():
form = DatabaseForm()
if form.validate_on_submit():
print form.images.data
else:
print form.errors
return render_template('example.html',form=form)
if __name__ == '__main__':
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment