Hi Anthony,
Thanks for your advice. In the end I wrote a function to verify that the
emails were the same and attached it to the onvalidation callback as
follows:
auth.settings.register_onvalidation = verify_email
This verify email function then manually adds an error flag to the form:
form.errors['email_two'] = 'emails do not match'
I then create the error manually in the html (as I am using form.custom
anyway)
{{=INPUT(_name="email_two", _type="text", _class="string",
id="auth_user_email_two")}}
{{if form.errors.email_two:}}
{{=DIV(form.errors.email_two, _class="error")}}
{{pass}}
Cheers,
John
On Thursday, March 1, 2012 8:28:21 PM UTC+1, Anthony wrote:
>
> Maybe look at how Auth.register does it for the password field:
> http://code.google.com/p/web2py/source/browse/gluon/tools.py#1905. In
> your user function, you might do something like:
>
> def user():
> if request.args(0) == 'register':
> form = auth.register(onvalidation=verify_email)
> [code to add the email verification field to the form]
> else:
> form = auth()
> return dict(form = form)
>
> Then define a verify_email() function that takes the form and confirms
> that the two email address fields are the same (actually, at the time the
> onvalidation function is called within Auth.register, I don't think the
> second email address field will be present in the form, so you might have
> to access the value of the second field via request.vars instead of
> form.vars).
>
> Anthony
>
> On Thursday, March 1, 2012 1:01:34 PM UTC-5, greenguerilla wrote:
>>
>> Hi guys,
>>
>> I'm wondering if anyone knows of a good way to add a 'verify email' field
>> to auth's register form?
>>
>> I basically want to replicate the verify password functionality for the
>> email field but I notice that this is done inside the auth.register method
>> after the creation of the SQLFORM:
>>
>> if self.settings.register_verify_password:
>> ..... Create the verify password field and append to the form....
>>
>> Is there a nice way to do this without either modifying the auth.register
>> code or adding a bogus field to the auth_user table?
>>
>> Cheers,
>>
>> John
>>
>>