python - How to provide values for wtforms.BooleanField and how to add required validator? -
i using python-flask , putting small web-app.
i have boolean field below:
from wtforms import form, booleanfield, stringfield, passwordfield, validators, validationerror import json base.model import db_session, user class productform(form): name = .... price = .... **hasstone = booleanfield('hasstone', [validators.datarequired(message="please enter product frameshape")])**
in flask side smth below:
@app.route('/newproduct', methods=['post']) def newproduct(): """creates/edits proudct.""" updatesession() retjson = {'errmsg':[], 'data':{}} try: form = productform( request.form ); form.trimoffproductimageurl(); if request.method == 'post': if form.validate(): <<<<<<< stops here.
the form cannot validated reason don't know. complains datarequired validator cannot satisfied.
besides if take out validator, actual boolean value not copied on product form although can see correct values delivered server properties of request.form.
please let know if think of clue.
thank you, mehdi
Comments
Post a Comment