1

I am not able to submit a webform which is configured with honeypot.

I have tried following steps for anonymous user:

  1. Place the webform using the webform block in a page.
  2. Submit the webform. It got worked for 1st time.
  3. When trying to submit from 2nd time onwards it is showing a message "There was a problem with your form submission. Please refresh the page and try again.".
  4. After clearing cache only one submission is happening. From second submission onwards iit is not working.

Following are the module details: Drupal: 9.1.x Webform module:6.0.3 Honeypot: 2.0.1

There is no time restriction given in Honeypot module.

2
  • Any server-side caching layer? – leymannx May 20 at 8:03
  • @leymannx Caching is getting stored after every form submit. Following code fixed the issue: function MODULE_NAME_form_alter(&$form, FormStateInterface $form_state, $form_id) { $advanced_validation = \Drupal::config('honeypot.settings')->get('advanced_validation'); if ($advanced_validation) { $form['#cache'] = ['max-age' => 0]; } } – Siva May 20 at 15:28
1

This piece of code helped to solve the issue. Clearing the cache for every submission of a webform which is protected by honeypot.

    function MODULE_NAME_form_alter(&$form, FormStateInterface $form_state, $form_id) { 
      $advanced_validation = \Drupal::config('honeypot.settings')->get('advanced_validation'); 
      if ($advanced_validation) { 
        $form['#cache'] = ['max-age' => 0]; 
      } 
    } 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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