Monday, 30 September 2013

Unable to populate wtforms

Unable to populate wtforms

I am using flask, jinja2 and wtforms. I am trying to pre-populate form
fields , but somehow text fields are not populated in form but select
fields are.
forms.py
class DecoderForm(Form):
# Text Field
applicationIdentifier=TextField('App Identifier',
[ validators.Regexp('^\d{4}$',
message='Must be integer 4 digits long.')])
# Select Field
primaryPurchaseReqCode=SelectField('Primary Purchase Req Code',
[validators.Required(),],
choices=[
('','Choose one'),
('0','Number of units'),
('1','Value of qualifying items'),
('2','Value of total transaction'),
('3','Number of Pounds'),
('4','Number of Kilograms'),
('9','Cashier intervention required')])
views.py
@app.route('/decode',methods=['GET','POST'])
def decode():
form=DecoderForm(applicationIdentifier='samplesample',primaryPurchaseReqCode='1')
return render_template('decode.html',form=form)
decode.html
<form action=''>

</form>

No comments:

Post a Comment