I want to have an extra field in the register form but not in the auth_user table.
There has been some threads about this topic in the past.
In user.html I have added:
elif request.args(0)=='register':
form[0].insert(-1, DIV(
LABEL(T('registercode'),_class="control-label col-sm-3"),
DIV(
INPUT(_name='registercode', _placeholder="z.B. xs5trv", _class="form-control string"),
SPAN(_class="help-block"),
_class="col-sm-9"),
_class="form-group"))
pass
=form
and in db.py there is a simple validation code:
def validate_registercode(form):
print "reg", form.vars
if form.vars.registercode!="123":
form.errors.registercode="*** Error ***"
auth.settings.register_onvalidation=[validate_registercode]
This creates a nice form containing the new field "registercode". auth calls the validate_registercode, but form.vars does not contain the new field "registercode", only the fields last_name, first_name and so on. What is wrong?
And: is there a better way to add a new field together with its classes?