Adding a captcha, either through captcha admin or using hook_form_alter, to a views exposed filter form

1) loads initially with
* Math question field is required.
* The answer you entered for the CAPTCHA was not correct.

2) after submission incorrectly gives:
The answer you entered for the CAPTCHA was not correct.

reproduced by another user here:

[#comment-4095116]

"It seems an exposed view filter form is automatically submitted (before you get the chance to fill it in) in order to show a default view."

Comments

ransomweaver’s picture

andykisaragi’s picture

Same issue here...

konrad1811’s picture

When I added CAPTCHA on exposed view filter using admin link there was a kind of error [wrong form id was taken - from div not from views exposed filter form].

When I addedn correct ID form and assigned proper CAPTCHA [image] there was no error, however CAPTCHA didn't show.

I believe this is ID form confusion.

oh forgot my CAPTCHA version... but maybe here the same?

elachlan’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

Is this still an issue?

genjohnson’s picture

Version: 6.x-2.4 » 7.x-1.1

I'm running into this issue with the latest version, 7.x-1.1.

genjohnson’s picture

Status: Postponed (maintainer needs more info) » Active
radj’s picture

Same issue here. I tried adding the view exposed form ID into the Captcha settings and disabled captcha for that form but it still shows up.

alfredo.ardito’s picture

Same issue. It works fine if I disable "Default challenge on non-listed forms."

michalgreksak’s picture

I have a Webform as a contact form with reCAPTCHA and in the Captcha settings (admin > config > people > captcha) have "Default challenge on non-listed forms." enabled. After that, when I set the view exposed form I get the message "The answer you entered for the CAPTCHA was not correct". That I needed to turn of a Captcha in the view and also has "Default challenge on non-listed forms." enabled for webform to be working.
I found a simple solution:
in the Captcha settings I set a new form_id
*views_exposed_form* and set it to *- No challenge -*
From that moment I have the view exposed form disabled and everything works as I expecting =)
I have Captcha 7.x-1.3

dmkelner’s picture

Thanks @michalgreksak. That's exactly my use case.

florianmuellerCH’s picture

Priority: Normal » Major

This still seems to be an issue - isn't there a way on the reCAPTCHA plugin (or the CAPTCHA plugin) to define that the option "Default challenge on non-listed forms" is only valid for not listed webforms (currently it is not only inserted on webforms but also on view filter forms).

EDIT: We achieved a solution on our project adding a hook to one of our core modules, with the help of stackexchange. Just set the default challenge to "none" and the default captcha to "reCAPTCHA" and add the following hook:

function hook_form_alter(&$form, &$form_state, $form_id) {
  // Check to see if it is any webform, regardless of ID
  // Also check to see if user has 'skip CAPTCHA' permissions
  if ((strstr($form_id, 'webform_client_form')) && !(user_access('skip CAPTCHA'))) {
    $form['my_captcha_element'] = array(
      '#type' => 'captcha',
      // default captcha type set at
      '#captcha_type' => 'default',
    );
  }
}
Chris Matthews’s picture

Version: 7.x-1.1 » 7.x-1.x-dev

Version change only

ghobadipouya’s picture

i have an error with recaptcha "Im not robot" in my exposed views drupal...
The answer you entered for the CAPTCHA was not correct.
please help me.....

vivdrupal’s picture

Even with Captcha 7.x-1.7, a Views Exposed form seems to be pre submitted.
Consequently, as in the issue reported ten years back, the page loads with the error "Math question field is required."

Anybody’s picture

Priority: Major » Normal
Status: Active » Needs work

Setting the priority back to normal, as it's more an edge-case here. But I'd still be interested to commit a fix, if someone provides a working solution!