Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Google ReCaptcha not working on contact form

form

Started by Chris Lloyd 7 years ago · 2 replies · 2177 views
7 years ago

I have setup V2 - checkbox style Google recaptcha for my client and I cannot get the form plugin to play nice with Google. Every time I test the form I get the following error back "reCAPTCHA bot protection has identified this form submission is problematic".

Here is my contact form yaml.

YAML
title: Contact
cache_enabled: false
form:
    name: contact-form
    action: '/contact#contact'
    fields:
        name:
            label: Name
            placeholder: Name
            type: text
            autofocus: true
            validate:
                required: true
        email:
            label: Email
            placeholder: Email
            type: text
            validate:
                required: true
        subject:
            label: Subject
            placeholder: Subject
            type: text
            validate:
                required: true
        message:
            label: Message
            placeholder: 'What''s on your mind?'
            type: textarea
            rows: 5
            validate:
                required: true
    buttons:
        submit:
            type: submit
            value: Send
    process:
        captcha: true
        reset: true
        email:
            from: '{{ config.plugins.email.from }}'
            to: '{{ config.plugins.email.to }}'
            subject: 'langford-assoc.com: {{ form.value.name|e }} - {{ form.value.subject|e }}'
            body: '{% include ''forms/data.html.twig'' %}'
        save:
            fileprefix: contact-
            dateformat: Ymd-His-u
            extension: txt
            body: '{% include ''forms/data.txt.twig'' %}'
        message: 'Thank you for getting in touch!'

I have already updated grav + form plugin to latest versions, and I have configured the form plugin with the correct site key and secret key.

It is work noting that I have also tried changing the form options from the above to the following with no success either.

YAML
captcha:
            recaptcha_secret: 6Le...ldK

Does anyone have Google ReCaptcha V2 - Checkbox working with form plugin? I have tried googling this and am finding lots of conflicting information about how to use recaptcha with Grav forms.

last edited 11/01/19 by Chris Lloyd
4 years ago

I have the same problem, I followed the following page : https://learn.getgrav.org/16/forms/forms/fields-available#captcha-field ,

This is mine :

title: Eventi
menu: Eventi
form:
name: Form-Eventi-01
fields:

YAML
        name: nome
        label: Nome
        placeholder: '(il tuo nome)'
        autofocus: 'on'
        autocomplete: 'on'
        type: text
        validate:
            required: true
    -
        name: email
        label: Email
        placeholder: '(la tua email)'
        type: text
        validate:
            rule: email
            required: true       
    -
        name: messaggio
        label: Messaggio
        size: long
        placeholder: "(inserisci il link e descrivi brevemente l'evento)"
        type: textarea
        validate:
            required: true        

g-recaptcha-response:
        label: Captcha
        type: captcha
        recaptcha_not_validated: 'Captcha not valid!'
buttons:
    submit:
        type: submit
        value: Invio
    reset:
        type: reset
        value: Reset
process:
    captcha: true
    email:
            from: '{{ config.plugins.email.from }}'
            to:
                - '{{ config.plugins.email.from }}'
                - '{{ form.value.email }}'
            subject: 'napoli360.it] un nuovo Evento da {{ form.value.email|e }}'
            body: '{% include ''forms/data.html.twig'' %}'
    save:
            fileprefix: feedback-
            dateformat: Ymd-His-u
            extension: txt
            body: '{% include ''forms/data.txt.twig'' %}'
    message: "Grazie per averci contattato ! tieni d'occhio Eventi Culturali Napoli"
    display: thankyou

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 53 10 hours ago
Support · by Anna, 3 days ago
2 60 13 hours ago
Support · by Justin Young, 14 hours ago
1 30 14 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 56 5 days ago