Problem/Motivation

Some modules, for example Forward or Webform, are using a generated form_id that includes something highly variables (eg. NID). If we want the CAPTCHA to be applied on these forms we need to do it manually or we need to create one captcha_point for each node.

Proposed resolution

Try to load the captcha_point based on the base_form_id if there is none (or none active) for the form_id.

Remaining tasks

Patch, Review, Commit

User interface changes

Maybe an addition in the captcha_point creation/edition form to tell the user they can use the base_form_id.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DuaelFr created an issue. See original summary.

DuaelFr’s picture

Status: Active » Needs review
FileSize
1.29 KB

Status: Needs review » Needs work

The last submitted patch, 2: captcha-use_base_form_id-2839891-2.patch, failed testing.

DuaelFr’s picture

Status: Needs work » Needs review
FileSize
1.68 KB
1.28 KB

Ok! I thought all forms had that method.
Fixed!

zrpnr’s picture

I like this solution, it worked on my webform that had an id like "webform_submission_contact_node_1234_form"
It was difficult to find the base form id, for webform it is "webform_submission_form"

Once I found that I created a new captcha point with that id and the captcha appeared.

jzavrl’s picture

Status: Needs review » Reviewed & tested by the community

The patch looks good and can confirm it also works well.

The way Webform generates form_id, I think this is a much needed functionality in the module.

Thanks!

elachlan’s picture

Status: Reviewed & tested by the community » Needs work

There seems to be a merge conflict. Can you re-roll the patch?

Prashant.c’s picture

Status: Needs work » Needs review
FileSize
1.67 KB

Patch re-rolled.

  • elachlan committed 483780b on 8.x-1.x authored by Prashant.c
    Issue #2839891 by DuaelFr, Prashant.c: Allow to target the base_form_id
    
elachlan’s picture

Status: Needs review » Fixed

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mkrizaj’s picture

Category: Feature request » Bug report

Hi guys.

It looks like this is not working anymore. I've found this change record which says that webform base form id includes the webform id in newer versions. (https://www.drupal.org/node/2959264)

I've debugged the captcha module and noticed what was changed.

My case example:

$base_form_id = webform_submission_test_form_form;
$form_id = webform_submission_test_form_add_form;

I think we need to find a way to apply Captcha to all web forms instead of adding Captcha point for each webform separately.