I have successfully managed to add (re)CAPTCHA to my custom registration form. However, when I change the form so that my reCAPTCHA widget is output inside a jQuery dialog box, the form stops working. To be more precise, Drupal outputs the following error after submitting the form:

CAPTCHA validation error: unknown CAPTCHA session ID. Contact the site administrator if this problem persists.

The following lines in my template.php add CAPTCHA to the registration form:

$form['my_captcha_element'] = array(
	'#type' => 'captcha',
	'#captcha_type' => 'recaptcha/reCAPTCHA',
);
$out->my_captcha_element = drupal_render($form['my_captcha_element']);

and here's the registration page part:

<?php $register_form = get_user_register_form(); ?>
...
...
...
<div id="dialog" title="CAPTCHA:">
   <?php print $register_form->my_captcha_element; ?>
</div>

The #dialog div is hidden until the user clicks on "Register", which outputs the widget inside a dialog window. One thing I noticed is that jQuery moves the whole element outside the registration form, to the very bottom of the page source. The "Submit" button which is part of the dialog window, and is supposed to forward the form information, works fine.

Comments

wundo’s picture

Issue summary: View changes
Status: Active » Closed (outdated)