0

Honeypot is active on my site (Drupal 9) for all forms. When I created the template file for the contact form "webform--contact.html.twig", I can't get the honeypot default hidden field "url".

I tried :

  • {{ content.url }}
  • {{ element.elements.url }} ...

How can I get the honeypot hidden field "url" in my contact twig file?

/* templates/webform/webform--contact.html.twig */

  <form{{ attributes }}>
        {{ title_prefix }}
        <div class="row">
          <div class="col-md-6">
            {{ element.elements.email }}
            //  Honeypot hidden field "url" ? 
                ...
          </div>
          <div class="col-md-6">
            {{ element.elements.message }}
            {{ element.form_build_id }}
            {{ element.form_token }}
            {{ element.form_id }}
            {{ element.elements.actions }}
          </div>
        </div>
        {{ title_suffix }}
  </form>

1 Answer 1

2

For me {{ element.url }} works. It seems to me that Honepot does not add the field to the elements subarray. And be sure not to be logged in with a role that has the permission to bypass honeypot protection.

Tip: with Devel module and Xdebug installed you can set a breakpoint in your twig file with {{ devel_breakpoint() }} which allows you to stop your script at this point and check which variables can be used in your twig file.

1
  • Thank you @Tobias for this response. Sep 14, 2022 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.