I would like to implement the example
of
http://web2py.com/books/default/chapter/29/07#Adding-extra-form-elements-to-SQLFORM
inside auth.register form.
Then try to validate if its checked.
auth.settings.register_onvalidation = checkaceito
And I set that users need approval to login:
auth.settings.registration_requires_approval = True
But I had a problem:
- the extra element 'agree' is not passed to the onvalidation function
Here the code:
def user():
db.auth_user.id_perfil.requires = []
db.auth_user.id_perfil.default = 1
form=auth()
def checkaceito(form):
form.vars.id_perfil = 1
print 'CHECK:',form.vars
if not form.vars.agree:
form.errors.agree = 'Para o cadastro eh necessario aceitar
os termos de contrato.'
##session.flash = 'Para o cadastro eh necessario aceitar os
termos de contrato.'
if request.args(0)=='register':
if form.errors: print form.errors
db.auth_user.id_perfil.writable = False
db.auth_user.id_perfil.readable = True
auth.settings.register_onvalidation = checkaceito
form=auth.register()#SQLFORM(db.auth_user)
checkbox = TR(LABEL('Eu concordo com os termos de
contrato'),INPUT(_id='agree', _name='agree', value=True, _type='checkbox'))
form[0].insert(-1,checkbox)
return dict(form=form)
Here the print I got in checkaceito function:
CHECK: <Storage {'first_name': 'programando', 'last_name': 'python',
'password_two': '123456', 'id_perfil': 1, 'password':
<gluon.validators.LazyCrypt object at
0x045F8A30>, 'ativo': 'on', 'email': '[email protected]'}>
What am I missing o what I can do it to work?
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.