2

I have integrated a multi step form through the drupal webform modules. Need to add a captcha at the end of the form. I have used captcha module for it..but while enabling the module and assigning the form id from the backend it is adding the captcha to each step forms.

Can any one please help me how to add the captcha at the end of the form.

1

One thing that may work is altering the form using HOOK_form_alter() and than modifying the form to show the captcha only on the last step something as below:

/**
 * Implements hook_form_alter().
 */
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  // Get the form id through dpm() or print_r().
  switch ($form_id) {
    // Add the form id as here.
    case 'webform_client_form_form-id':
      // Get the value of step number and the total number of steps in form.
      $page_num = $form['details']['page_num']['#value'];
      $page_count = $form['details']['page_count']['#value'];

      // Check if its not the last step and catcha present in form.
      if (($page_num != $page_count) && (!empty($form['captcha']))) {
        // Remove the captacha from the form.
        unset($form['captcha']);
      }
    break;
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.