Add recaptcha only to the last step of a wizard

Created on 14 April 2021, over 3 years ago
Updated 4 July 2023, over 1 year ago

Problem/Motivation

1. multi-step webform shows/requires recaptcha on every page...
2. ...but it fails validating starting the second step

the following error shows up:
"There was an error during validation of your form submission, please try to reload the page and submit form again."

reason seems to be that the the token is already set on JS end, so AJAX submit is not prevented
but the simple_recaptcha_message is missing from the form state

Steps to reproduce

Create a webform with multiple wizard pages.
Add the recaptcha handler.
Try to fill the form as a visitor
- you will get recaptcha on every step.
- on the second step it will fail with generic error.

Proposed resolution

Workaround and UX improvement: only add recaptcha to the last step of the form.
(or maybe adding to the first step only would make more sense?)

Remaining tasks

Create a patch.

User interface changes

None

API changes

None.

Data model changes

None.

Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

🇷🇴Romania reszli Târgu Mureș

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇧🇪Belgium gilles_webstanz

    Hello,

    I think we can close this issue because when you update to the last version webform & simple google recaptcha it works fine.

    Have a nice day.

  • 🇮🇳India mohit_aghera Rajkot

    I'm using patch #3 in webform 6.1.4
    It works fine.
    Attaching patch with more restrictions as I noticed following errors while indexing the content.
    TypeError: array_keys(): Argument #1 ($array) must be of type array, null given in array_keys() (line 142

    So doing extra check to ensure that `$pages` is array will not trigger the error.
    Keeping in needs work until we have consensus around whether we need to close it or keep it active.

Production build 0.71.5 2024