When submitting a custom form in D8, it keeps on giving me:
"Submission failed. Please reload the page, ensure JavaScript is enabled and try again."
It does correctly switch the /antibot form action upon mousemovement.
But i still end up with this error.
I have been searching the issue queue, but cant seem to find any docs/reference to this.
The form is submitted via a regular submit button (so, not submitted programatically).
Any help would be much appreciated.
Issue fork antibot-3247315
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
gaurav.kapoor commentedIs the console showing any JS errors when you are on the form page?
Comment #3
guardian87 commentedNo JS errors displayed.
I have uninstalled the module for now, as it renders my forms unusable, in the sense that nobody can submit them anymore...
Comment #4
gaurav.kapoor commentedDid you try reinstalling the module, the issue goes away for most of the users after that.
Comment #5
guardian87 commentedYes we did.
No difference...
Comment #6
guardian87 commentedTo whom it may concern.
When rendering a custom form, on a field by field basis, you need to make sure to render:
{{ form.antibot_key }}
{{ form.antibot_no_js }}
That solved it.
Comment #7
gaurav.kapoor commented@guardian87 Thanks for sharing this information. I will keep this issue open and use it for improving the documentation.
Comment #8
gaurav.kapoor commentedComment #9
seppe beelprez commentedHad the same issue when updated to 1.5, happened on a custom form with field by field basis. Adding form.antibot_no_js didn't solved it.
For now I have to go back using 1.4
Comment #10
jonas-gerosa361I will take a look at it.
Comment #11
gaurav.kapoor commentedComment #12
jonas-gerosa361Comment #13
gaurav.kapoor commentedComment #14
seppe beelprez commentedWhat I mentioned in #9 isn't a problem anymore. I assume it had something to do with another module. My apologies!
Comment #15
camslice commentedI'm facing the same issue on a custom user registration form. Was working fine until the v1.5 upgrade, so I've downgraded back to v1.4 for the time being. Drupal 9.3.2, PHP 7.4.25
I'm including the antibot key in a twig template called "form.html.twig" like so:
Comment #16
gaurav.kapoor commentedComment #17
seppe beelprez commentedI had this issue again recently and I noticed that I had printed the {{ attributes }} twice in the same twig template #facepalm, so I thought to post this here as well in case anyone did something the same as me.
Comment #18
jumpsuitgreen commentedAntibot Module version: 2.0.2
Drupal Version: 9.3.12
I had custom Webforms that weren't working on a site with the Antibot module enabled and protection enabled in the Webforms settings. Once I included
{{ element.antibot_no_js }}{{ element.antibot_key }}in the form Twig template, everything worked fine. I only needed to include it once in the template and I did so at the very bottom with some of the other hidden fields likeform_tokenandform_id. This bit of information is no where in the documentation unless I missed it somewhere. Preferably, the module page and the README file. Here is what my block looks like the the bottom of the webform Twig template:Comment #19
fpc_drupal commented#18 Worked for my custom forms! Thank you very much jumpsuitgreen! Pretty incredible that this solution was posted at the exact time as I was having the problem.
Comment #20
ronalpha commentedform_id was returning null or empty when executing form validation logic.
This code
_antibot_generate_key($form['#form_id']);in antibot.moduleChanged to
_antibot_generate_key($form_state->getValue('form_id'));Now the form_id is returning the correct value and the form is processed with no antibot related errors.
Comment #21
danrodComment #23
danrodI included the instructions for the fix from #18 in the README.md file in this MR.
Can be reviewed anytime.
Comment #24
danrodComment #25
danrodI'll merge this, it's just documentation changes.
Thank you everyone.
Comment #27
danrodComment #29
danrod