accessing fields as attributes in validators

19 views
Skip to first unread message

Jim Gregory

unread,
Sep 4, 2015, 9:58:01 PM9/4/15
to web.py
The documentation suggests you can compare fields when validation a form by referring to the form elements as attributes:


signup = form.Form(
    form.Textbox('username'),
    form.Password('password'),
    form.Password('password_again'),
    validators = [form.Validator("Passwords didn't match.", lambda i: i.password == i.password_again)]
)

But this doesn't appear to be right. The only way to access the
individual field elements if by referring to them as keys:

signup = form.Form( form.Textbox('username'), form.Password('password'), form.Password('password_again'), validators = [form.Validator("Passwords didn't match.", lambda i: i['password'] == i['password_again']] )

Is this correct or am I missing something?

This post from Anand back in 2007 indicates it *could* be possible:

https://groups.google.com/forum/#!searchin/webpy/validator/webpy/ibMOuTNesBg/NhLXJZfl8ekJ

but maybe it was never implemented?

Reply all
Reply to author
Forward
0 new messages