Another noob question.

I am trying to put a v.2 recaptcha into a response form.
I have searched the forum, the book, web2pyslices etc.
and have had no joy.

I thought this was the answer
https://groups.google.com/forum/#!topic/web2py/eeMT2Bb-KYA
but want it to happen every time regardless so discarded the if test.

It errors and does not work.
No recaptcha widget appears on the form.  The "I am not a Robot" should 
appear with v.2
when you fill the form and hit submit it errors in a response flash.
No email is sent.

the following is my code:

thanks.

def contact():
    from gluon.tools import Recaptcha
    form = SQLFORM.factory(
        Field('your_name', requires=IS_NOT_EMPTY()),
        Field('your_email', 'string', requires = 
IS_EMAIL(error_message='invalid email!'), label = 'Email address'),
        Field('your_topic', 'string', label = 'Topic'),
        Field('your_text', 'text', label = 'Message'),
        )
    recaptcha_public = "..."
    recaptcha_private = "..."
    captcha = Recaptcha(request, recaptcha_public,recaptcha_private)
    form[0].insert(-1, TR('', captcha, ''))
    
    if form.accepts(request.vars,session):
        mail.send(to='alby@email',
                  subject = form.vars.your_topic +' from ' + 
form.vars.your_email,
                  message = form.vars.your_text )
        session.flash = 'Thank you, your form was submitted'
        redirect(URL('default','index'))

    return locals()

-- 
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