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

traxer - March 29, 2008 - 11:11
Project:CAPTCHA
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:soxofaan
Status:closed
Description
  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.

#1

traxer - March 29, 2008 - 11:23

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

#2

traxer - March 29, 2008 - 11:27
Version:6.x-1.0-rc1» 6.x-2.x-dev

#3

soxofaan - March 29, 2008 - 17:18
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

soxofaan - March 29, 2008 - 17:25
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

Anonymous (not verified) - April 12, 2008 - 17:31
Status:fixed» closed

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

#6

Todd Nienkerk - January 23, 2009 - 17:22

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

#7

Todd Nienkerk - January 23, 2009 - 17:29

Scratch that. User error!

#8

webengr - May 18, 2009 - 18:07
Status:closed» 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

webengr - May 18, 2009 - 18:11

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

webengr - May 18, 2009 - 18:16
Status:active» closed

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

soxofaan - May 18, 2009 - 22:12

@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

dyland - May 26, 2009 - 16:52

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

soxofaan - May 26, 2009 - 17:12

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

Ian Burge - November 6, 2009 - 07:49

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

 
 

Drupal is a registered trademark of Dries Buytaert.