Hello, everyone.
By default captcha doesn't shown on next step, if user fill it correctly on previous step:
1. Enter all info, except password confirmation ( http://clip2net.com/s/1WJEl ) Press Enter.
2. There is no captcha on next step ( http://clip2net.com/s/1WJFK ) Well, enter passwords and press Enter.
3. Done. http://clip2net.com/s/1WJxO
Works good on default registration form, but I have problem with my custom registration form: it shows warning on step 3 to fill captcha, but there was no captcha on step 2 ( http://clip2net.com/s/1WJQk )
I add captcha (and other fields) to my form this way:
$profile_form = drupal_get_form('user_register_form');
if (isset($profile_form['captcha'])) {
$my_form['captcha'] = $profile_form['captcha'];
}
My registration form works good. But I have no idea what to do with captcha. Please, help.
Thank you and sorry for my English.
Comments
Comment #1
soxofaan commentedThis is by design the default behavior. (also check out the "persistence" setting on the general CAPTCHA configuration page)
In which hook do you put this code?
Comment #2
trimboot commentedI'm sorry, that did not respond for a long time.
I create my form this way:
------------------------------
function my_module_menu() {
$items[REGFORM_URI] = array(
'title' => t('Become a Member!'),
'page callback' => 'regform_page',
'access callback' => 'user_register_access',
'file' => 'regform.pages.inc',
'file path' => drupal_get_path('module', 'regform'),
'type' => MENU_CALLBACK,
);
}
function regform_page($step = FALSE) {
...
...
$output['regform'] = drupal_get_form('regform_registration_form', $step, $invite_plan);
return $output;
}
function regform_registration_form($form, &$form_state, $url_step = FALSE) {
$profile_form = drupal_get_form('user_register_form');
// Add step fields to the form
// I use groupfield module
foreach($profile_form['#groups'][REGFORM_GROUPFIELD_PREFIX . $step]->children as $k => $field_name) {
if (isset($profile_form[$field_name])) {
$form[$field_name] = $profile_form[$field_name];
}
}
// needed in user_account_form_validate()
$form['#user_category'] = $profile_form['#user_category'];
$form['#user'] = $profile_form['#user'];
// add captcha
if (isset($profile_form['captcha'])) {
$form['captcha'] = $profile_form['captcha'];
}
return $form;
}
----------------------
The array $form created on second step (when we do not enter passwords correctly) looks like identical with array on first step. All fields presents in array. All fields are rendered on page, except Captcha and Mollom (I try Mollom too).
Thank you for answer.
Comment #3
soxofaan commentedhmm, it doesn't seem you are using standard techniques to build that form. I'm afraid that it is infeasable to support this system with the CAPTCHA module.
as an alternative, you might be interested in inserting CAPTCHA's into your forms in a programmatical way (instead of through the UI):
#743056: Document how to add a CAPTCHA programmatically
Comment #4
trimboot commentedThank you, sohofaan. Works good now. Here is my code:
--------------------
// add captcha
if (isset($profile_form['captcha'])) {
$form['captcha'] = array(
'#type' => 'captcha',
'#captcha_type' => $profile_form['captcha']['#captcha_type'], //image_captcha/Image
'#weight' => $profile_form['captcha']['#weight'],
'#input' => $profile_form['captcha']['#input'],
'#captcha_admin_mode' => $profile_form['captcha']['#captcha_admin_mode'],
'#captcha_validate' => $profile_form['captcha']['#captcha_validate'],
'#tree' => $profile_form['captcha']['#tree'],
'#required' => $profile_form['captcha']['#required'],
'#attributes' => $profile_form['captcha']['#attributes'],
'#title_display' => $profile_form['captcha']['#title_display'],
);
}
Comment #5
trimboot commentedClosed. ;)