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

Captcha not working

Started by Muut Archive 10 years ago · 3 replies · 612 views
10 years ago

Hello,
I’m creating a contact form using the documentation.
However, the captcha isn’t working (not showing).

The console outputs this error:

Error: Missing required parameters in RecaptchaOptions: sitekey

However, my recaptcha_site_key is defined.
Without the captcha, the form works perfectly fine.

Here’s the full (edited) contact page’s frontmatter:

title: 'Nous contacter'
visible: true
in_nav: true
coord: "Company address"
form:
action: /contact
name: contact
fields:

  • YAML
        name: name
        label: 'Votre nom complet'
        placeholder: 'Nom complet'
        type: text
        autofocus: 'on'
        validate:
            required: true
    
  • YAML
        name: company
        label: 'Votre société'
        placeholder: Société
        type: text
    
  • YAML
        name: email
        label: 'Votre adresse e-mail'
        placeholder: E-mail
        type: email
        validate:
            rule: email
            required: true
    
  • YAML
        name: phone
        label: 'Votre numéro de téléphone'
        placeholder: Téléphone
        type: text
    
  • YAML
        name: message
        label: 'Votre message'
        placeholder: Message
        type: textarea
        validate:
            required: true
    
  • YAML
        name: g-recaptcha-response
        label: Validation
        type: captcha
        recaptcha_site_key: I-WROTE-THE-KEY-HERE
        recaptcha_not_validated: 'Validation incorrecte.'
        validate:
           required: true
    

    buttons:

    YAML
       type: submit
       value: Envoyer
    

    process:

    YAML
       captcha:
           recaptcha_secret: I-WROTE-THE-OTHER-KEY-HERE
    

    -
    email:
    from: '{{ form.value.email }}'
    from_name: '{{ form.value.name|e }}'
    to: '{{ config.plugins.email.to }}'
    subject: '[Site] Message de {{ form.value.name|e }},{% if form.value.company %} ({{form.value.company|e }}){% endif %}'
    body: '{% include ''forms/data.html.twig'' %}'

    TWIG
      save:
           fileprefix: contact-
           dateformat: Ymd-His-u
           extension: txt
           body: '{% include ''forms/data.txt.twig'' %}'
    

    -
    message: hop!

    TXT
       display: ok
    

Can someone see what’s wrong?
Thanks!

10 years ago

Where are you setting the recpatcha_site_key? Can you paste your YAML where this is set between --- marks so it displays it as code with proper indents etc. It's basically impossible to tell if you have an error when you paste your YAML as regular text as all the indents are lost, and they are crucial in YAML.

10 years ago

Actually the current version of the Form plugin has the recaptcha_site_key and recaptcha_secret with a typo.

Use recatpcha_site_key and recatpcha_secret (notice pt inverter) - I know this is a hassle, the next version will fix this (and still allow values with the typo, to avoid breaking existing working integrations)

10 years ago

@flaviocope: Thanks a lot! I lost so much time trying to find what was wrong, I would never have found this. It’s now working!

@rhukster: Thanks for the tip about ---, I didn’t see the indents has been removed in my message.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1361 9 years ago
Archive · by Muut Archive, 9 years ago
2 939 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2958 9 years ago
Archive · by Muut Archive, 9 years ago
3 1122 9 years ago