I have some custom requirements for registration, but I still want to use auth.register() with a custom form view to rely on web2py's form validation.
Background: I have a table of allowed email addresses with a generated secret hash. (kind of like an invitation only registration). When you access the secret invite link I look up the secret hash in the database and want to use the auth.register() form without the email field so I can set the user's email to the one I already have. I have come across 2 problems: 1. When my custom form doesn't include an email field, the form does not seem to be processed and just redirects to itself. (see comment in view below) 2. When I set the email field to be not writable, the registration fails and I get a ticket: Traceback (most recent call last): File "/Users/flo/Applications/web2py/gluon/restricted.py", line 205, inrestricted exec ccode in environment File "/Users/flo/Applications/web2py/applications/main/controllers/signup.py"<http://127.0.0.1:8000/admin/default/edit/main/controllers/signup.py> , line 138, in <module> File "/Users/flo/Applications/web2py/gluon/globals.py", line 173, in <lambda> self._caller = lambda f: f() File "/Users/flo/Applications/web2py/applications/main/controllers/signup.py"<http://127.0.0.1:8000/admin/default/edit/main/controllers/signup.py> , line 62, in complete form = auth.register(onaccept=on_accept) File "/Users/flo/Applications/web2py/gluon/tools.py", line 1959, in register user = Storage(table_user._filter_fields(user, id=True)) File "/Users/flo/Applications/web2py/gluon/dal.py", line 6683, in_filter_fields return dict([(k, v) for (k, v) in record.items() if k AttributeError: 'NoneType' object has no attribute 'items' Here is the code that I think is relevant for this: Inside my controller: signup_data = db(db.signup.signup_key==signup_key).select(db.signup.ALL).first() def on_accept(form): # does a whole bunch of setting up additional db entries pass # stripped out for the example auth.settings.table_user.email.default = signup_data.email auth.settings.table_user.email.writable = False # causes error form = auth.register(onaccept=on_accept) # line 62 (see error log) Inside my view: {{=form.custom.begin }} <div style="display: none;"> {{ # removing this field from markup causes the form submission to fail. :/}} {{=form.custom.widget.email }} </div> {{=form.custom.widget.first_name }} ... all the other widgets ... {{=form.custom.end}} --