- Issue created by @JensBNS
- Status changed to Postponed: needs info
almost 2 years ago 12:46pm 2 February 2023 - 🇵🇱Poland sandboxpl Poland 🇵🇱
Hi, the webform submodule provides webform specific handler,
please remove webform ID from /admin/config/services/simple_recaptcha
and add handler via /admin/structure/webform/manage/{webform_id}/handlersIf the problem still occurs, please check the page source, the webform should contain a hidden input with name "simple_recaptcha_token" ,
and this one should be prefilled when you click on submit button, also please check if there's no errors showing up in browser consoleIf this doesn't solve your problem please add some additional details such as:
- webform module version
- steps to reproduce with https://simplytest.me/
- or dump webform configuration ( yml dump would be nice )
As webform module is extremely flexible and provides a lot of contribs extending the default functionality,
it is hard to test and cover all scenario, thus if you could provide more usueful details and steps it will be easier to dig in :) - 🇵🇱Poland sandboxpl Poland 🇵🇱
oooh, w8, I think it might be related to the latest commit making the module compatible with drupal 10, see: #3289651 📌 Automated Drupal 10 compatibility fixes Fixed
We have moved from deprecated jquery/once to , see:
https://www.drupal.org/node/3158256 →I believe that for core versions lower than 9.2.x JS is now throwing errors related to missing once function, can you confirm that ?
Hi
I'm getting the same error. I will offer my findings for hopeful solution..
When I was debugging it I noticed thath the simple_recaptcha_token is set successfully when inspecting with dev tools.
But on the validation part the $form_state->getValue('simple_recaptcha_token') is empty.
So I checked the form payload on submission, and the payload also was empty.Any idea what could cause this or how to solve this?
Sorry English is not my first language.
Thanks.
- 🇵🇱Poland sandboxpl Poland 🇵🇱
@forzakenus which drupal core version are you using for the testing? if it is below 9.2.x it is most likely caused by following change:
https://www.drupal.org/node/3158256 →
We are planning to drop support for Drupal core 8.x as it is not supported anyway. @sandboxpl
I'm using latest d9 security release so 9.5.5.
Also I think i should mention that I'm using multiple webforms with ajax.- 🇳🇱Netherlands Gerben Spil
We are having the same issue and I have found the cause, but not yet the solution. In our case we have a node add form that anonymous users can submit. On this form we have recaptcha v3. There is also a file field, where the user can upload an image. This file field is the culprit. The upload is handled with AJAX and this triggers the validation of the form. But the token is not generated untill you use the submit button of the form. So when the file uploads there is no token in the form and the validation fails.
Drupal version: 9.5.3
Module version: 1.0-beta7Steps to reproduce:
- a form without AJAX handling, for example a node add form
- a field with a file upload
- upload the file
- press submit button - 🇳🇱Netherlands Gerben Spil
Not sure if the following code is valid so I do not add a patch here, but it works in my project.
public function validateCaptchaToken(&$form, FormStateInterface &$form_state) { $triggering_element = $form_state->getTriggeringElement(); if ($triggering_element['#submit'][0] == 'file_managed_file_submit') { return; }
- Status changed to Active
about 1 year ago 12:57pm 6 October 2023 - 🇧🇬Bulgaria valthebald Sofia
once() should explicitly pass the form instead of relying on "this" argument. Also, when chaining Drupal.Ajax.prototype.beforeSubmit(),
it's better to use Function.call() instead of direct invocation, to pass thisArgument to original function. - 🇧🇬Bulgaria valthebald Sofia
On a separate note (and this probably deserves separate issue), I don't quite understand isFormActions check. Triggering element is not necessarily part of .form-actions, no?
if (typeof currentFormIsRecaptcha !== 'undefined') { let isFormActions = $(this.element).closest('.form-actions').length; let token = $form.find('input[name="simple_recaptcha_token"]').val(); if (isFormActions && (typeof token === 'undefined' || token === '')) { this.ajaxing = false; return false; } }
- Open on Drupal.org →Core: 10.1.4 + Environment: PHP 8.1 & MySQL 5.7last update
about 1 year ago Not currently mergeable. - @valthebald opened merge request.
- last update
about 1 year ago 38 pass - 🇧🇬Bulgaria valthebald Sofia
To answer original concern of @JensBNS - Drupal 8.9.2 won't work with the latest versions of simple_recaptcha 8.x-1.x, because core/once library was introduced only in 9.2.0, see CR [#3158256]
- Issue was unassigned.
- Status changed to Needs review
about 1 year ago 8:17am 17 October 2023 - last update
about 1 year ago 38 pass