auth.register() both creates the form and processes it (i.e., running the 
validations), so anything you add to the form later will not be part of the 
validation. You can instead handle the validation manually by checking 
request.post_vars.f_zipcode. Alternatively, you could create your own 
registration form and skip auth.register() altogether.

Anthony

On Wednesday, January 27, 2016 at 10:39:22 AM UTC-5, Spokes wrote:
>
> I've manually added a field to the auth.register() form, but validation is 
> not performed for the field upon form submission. The code is as follows:
>
> def create_zipcode_field_for_register_form():
>     input_zipcode = INPUT(_class = 'span4 string', _name = 'f_zipcode', 
> _id = 'f_zipcode', 
>                           _placeholder = T('Recommended'), requires = 
> IS_LENGTH(5, 3))
>
>     div_password_confirm_controls = DIV(input_zipcode, SPAN(_class = 
> 'help-block'), _class = 'controls')
>     
>     label = LABEL(T('ZIP'), _class = 'control-label')
>     return DIV(label, div_password_confirm_controls, _id = 
> 'f_zipcode__row', _class = 'control-group')
>
> def custom_register():
>    ...
>    auth.settings.formstyle = 'bootstrap'
>    form = auth.register() 
>    form.element('#auth_user_username__row', replace = lambda x: x + 
> create_zipcode_field_for_register_form())
>    return dict(...)
>
> Is there a way to force the validation to be performed for the 'f_zipcode' 
> input?
>
> The 'f_zipcode' field pertains to a table other than auth_user, and I'd 
> like to avoid the 'auth.settings.extra_fields' route of solving this 
> problem. 
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to