Download & Extend

Illegal form_id when assigning a CAPTCHA to a form generated by Webform module

Project:CAPTCHA
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:soxofaan
Status:closed (fixed)

Issue Summary

  1. Created a form with the webform module,
  2. checked "Add CAPTCHA administration links to forms",
  3. visited a form I created with the Webform module,
  4. clicked the link "Place a CAPTCHA here for untrusted users."
  5. clicked "Save".

I recieved a warning "Illegal form_id" on the "CAPTCHA point adminstration" page.

Comments

#1

Form ID of the form is "webform_client_form_21". CAPTCHA module validates Form IDs using /^[a-z_]+$/.

#2

Version:6.x-1.0-rc1» 6.x-2.x-dev

#3

Version:6.x-2.x-dev» 6.x-1.x-dev
Assigned to:Anonymous» soxofaan
Status:active» patch (to be ported)

Good catch
fixed in HEAD by http://drupal.org/cvs?commit=108203
This commit also includes the first SimpleTest tests for CAPTCHA module, yay!
(Tests cover the CAPTCHA point administration)

#4

Status:patch (to be ported)» fixed

fixed for 6.x-1.x by http://drupal.org/cvs?commit=108204

(issue not applicable to 5.x-3.x, but it is applicable to issue/patch http://drupal.org/node/214557#comment-777792)

#5

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

#6

Is there any chance of this fix being backported to 5.x? I'm experiencing the same problem in 5.x-3.2.

#7

Scratch that. User error!

#8

Status:closed (fixed)» active

I am using drupal 6.12
with webform 6.x-2.6 2009-Feb-16
with captcha
captcha-6.x-2.0-beta5.tar.gz

oops using beta..

and I looked and the form id generated by webform module is "webform-client-form-7"

note it is using hyphens, -, and not underscores, _

I get the illegal notice with that form ID.

I was able to enter it into the captcha page with underscores, without the illegal notice,
but it is using hyphens so that does not help.

I Just updated to the dev capatcha from May 18 - it also fails, Illegal form_id

#9

hmmm,

in the file captcha/captcha.admin.inc

I added a hypen after the pregmatch for a-z0-9_

Will see what it does...

if (!preg_match('/^[a-z0-9_-]*$/', $form_id)) {

#10

Status:active» closed (fixed)

Alright, crazy webrower inspect element showed id with hyphens...
getting confused, after updates the form id is showing with undescores not hyphens...

so disregard.

apologies.

#11

@webengr: The internal form id in Drupal is always with underscores,
when rendered in HTML, the underscores are replaced with hyphens in some places like in the <form ...> element, but there should also be an hidden element like
<input type="hidden" name="form_id" id="edit-comment-form" value="comment_form" />
which shows the real form id (comment_form in this case)

#12

It was rejecting my form id due to camel casing - I fixed by adding ignore case to preg_match i.e.
if (!preg_match('/^[a-z0-9_-]*$/i', $form_id)) {

#13

How do you get a camel cased form_id? A standard Drupal form_id is [a-z0-9_] only. Is it a custom module?

#14

Drupal forms use underscores, replace the hyphens with underscores and it should work.

nobody click here