Problem/Motivation

I want modules to be able to add / alter form ids to protect.

Proposed resolution

Add a suitable collect / alter hook.

Remaining tasks

Do it.

User interface changes

None.

API changes

New hook added.

Data model changes

None.

Issue fork antibot-3185636

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

geek-merlin created an issue. See original summary.

geek-merlin’s picture

Title: Allow other modules to opt-in forms » Allow other modules to opt-in forms for antibot
gaurav.kapoor’s picture

Status: Active » Postponed (maintainer needs more info)

@geek-merlin Can you provide more info here? I am not able to understand the purpose of the requested hook here.

gaurav.kapoor’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
svendecabooter’s picture

Status: Postponed (maintainer needs more info) » Active

Use case would be having a specific module that generates its form_id dynamically, or has a lot of forms with different IDs.
In the first case, the administrator could not enable Antibot for these forms, since they cannot add all dynamically generated form IDs to the antibot settings. In the second case, they would need to add a lot of form IDs manually.

Providing a hook would solve this issue, if the specific module would implement this hook and provide its form_ids to it. This would automatically enable Antibot on all of the forms by "specific module", without a site administrator having to configure something.

Ideally the hook would not alter the form_ids, but just decide whether the form_id the hook is called for, should use Antibot or not.
That way, the specific module could just return TRUE for all form_ids starting with e.g. "specific_form_"

paulocs made their first commit to this issue’s fork.

paulocs’s picture

Status: Active » Needs review

I have created a PR to create the hook. I think we can add the hook as @svendecabooter provided some useful use cases.

hmendes’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @paulocs.
Tested the code here locally and it worked for me. I did a simple implementation on a custom module setting the protection to TRUE on a specific form and it worked.

Tested with Drupal 9.5.1 and antibot 2.0.x-dev. Changing to RTBC.