Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
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:
Comments
Comment #2
geek-merlinComment #3
gaurav.kapoor CreditAttribution: gaurav.kapoor at Axelerant for Drupal India Association commented@geek-merlin Can you provide more info here? I am not able to understand the purpose of the requested hook here.
Comment #4
gaurav.kapoor CreditAttribution: gaurav.kapoor at Axelerant for Drupal India Association commentedComment #5
svendecabooterUse 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_"
Comment #8
paulocsI have created a PR to create the hook. I think we can add the hook as @svendecabooter provided some useful use cases.
Comment #9
hmendes CreditAttribution: hmendes at CI&T commentedThanks @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.