hello one and all,
below is some example code where I'm using Form and validation under that. the form.errors work ok under the validation function thus displaying the appropriate message when set.
however, when I try to update the form.vars['some_field'] value under the validation function, it does not change the value of that field. in the below example, the form.vars['plot_controller'] should add a '3' at the end of that field every time the form is submitted.
am I doing something wrong? thank you in advance, Lucas
@action("questions")
@action.uses("questions.html", db, auth, T, session)
def questions():
#code blah....
qfrm = Form(db.questions, record=(qidi if (qidi > 0) else None), deletable=False, validation=chk_question)
if qfrm.accepted:
qidi = qfrm.vars['id']
redirect(URL('questions', vars={'ridi':sR.id, 'qidi':qidi}, hash='sample'))
elif qfrm.errors:
flash.set(f'question errors: {qfrm.errors}')
#code blah....
return dict(etc....)
def chk_question(f):
v, e = f.vars, f.errors
#f.vars['plot_controller'] = 'NONE1' if isinstance(v['plot_controller'], str) and (v['plot_controller'].strip()[:4].lower() == 'none') else v['plot_controller']
f.vars['plot_controller'] = str(f.vars['plot_controller'])+'3'
#e['plot_controller'] = 'dude plot'
return f