Custom form - Submission fails

Created on 2 November 2021, over 2 years ago
Updated 20 March 2024, 3 months ago

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.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium guardian87

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States jumpsuitgreen

    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 like form_token and form_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:

                <div class="row">
                    <div class="col-md-2 offset-md-1 offset-lg-2">
                        {{ element.elements.message }}
                        {{ element.elements.url_redirection }}
                        {{ element.form_build_id }}
                        {{ element.form_token }}
                        {{ element.form_id }}
                        {{ element.elements.actions }}
                        # Antibot keys to render.
                        {{ element.antibot_no_js }}
                        {{ element.antibot_key }}
                    </div>
                </div>
            </div>
    </form>
    
  • #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.

  • πŸ‡ΊπŸ‡ΈUnited States ronalpha

    form_id was returning null or empty when executing form validation logic.
    This code _antibot_generate_key($form['#form_id']); in antibot.module

    Changed 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.

Production build 0.69.0 2024