i've just scoured the forums and the code itself and i'm wondering how i can reposition captcha on the contact form in particular. In particular, i'd like it to go ABOVE the submit button (others have posted about this on the forum but no answers)

i can hack the module and use 'weight' to make captcha go either way up on top of the form (default which looks poor) or all the way below the submit button at the form bottom (looks better but not ideal). i want it above the submit button.

This mostly involves inserting the captcha textfield element in the form correctly

i see the module implements form_alter (captcha_form_alter).. so it appears that that is the location where the repositioning should take place.

if this was a simple form, i think i could handle it. But because there are actually two Submits applied to the same form (i think?... one for the captcha and one to actually process the mail form). when i look at this function, it doesn't make sense to me. It also uses a function "call_user_func_array" and i can't find it in the api reference.

Can anyone either post the code or the way to fix this.

Ideally it would be customizeable in some way in the admin or overriding a function so the module doesn't have to be hacked.

I (and others) would probably really appreciate this.

thanks for any help anyone can provide

CommentFileSizeAuthor
#8 captchaweight.patch1.66 KBrobloach
#1 submit_last.patch502 bytesthesaint_02

Comments

thesaint_02’s picture

Status: Active » Needs review
StatusFileSize
new502 bytes

The captcha field below the submit button bothered me too and I have changed the captcha code to change this. I have attached a patch.

DiGiT’s picture

Thanks archangel, this patch works also for me. I'm using drupal 5.1 and applied the patch manually to the 'captcha.module,v 1.32 2007/01/30 19:44:46' captcha module.

jadams1-1’s picture

I have 2 'categories' in my registration form and the captcha apprears after the second one. Basically shows up in the middle of the registration form. It is on a 5.1 system.

jadams1-1’s picture

Sorry, the previous comment should read " I have 3 categories ...". Thanks

wundo’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev

If it's a 5.1 system, you should use HEAD version, not 4.7.

jadams1-1’s picture

I was using the 5.1 dev version. I tried the HEAD version and got a blank page. Apache error log says:

[error] [client 192.168.0.11] PHP Fatal error: Cannot use string offset as an array in /var/www/html/sites/default/modules/captcha/captcha.module on line 166, referer: http://192.168.0.10/

Thanks

ednique’s picture

I use 4.7.6 and had the same problem.
Most Captcha's appeared after the submit button...

And I fixed it, but I've done it in the textimage module in the textimage_captchachallenge function:

function textimage_captchachallenge(&$form) {
  /* altered by ednique :: captcha placement before submit button!
  $form['captcha_response'] = array (
    '#type' => 'textfield',
    '#title' => t('Captcha Validation'),
    '#default_value' => '',
    '#required' => TRUE,
    '#validate' => array('_captcha_validate' => array()),
    '#description' => t('Please type in the letters/numbers that are shown in the image above.'),
    '#prefix' => '<img src="' . url('_textimage/image/'.time()) . '" '.$imageSize[3].'  alt="Captcha Image: you will need to recognize the text in it."/>',
  );
  */
  $newform = array();
  foreach ($form as $name => $element) {
    if ($element['#type'] == 'submit'){
      $newform['captcha_response'] = array (
        '#type' => 'textfield',
        '#title' => t('Captcha Validation'),
        '#default_value' => '',
        '#required' => TRUE,
        '#validate' => array('_captcha_validate' => array()),
        '#description' => t('Please type in the letters/numbers that are shown in the image above.'),
        '#prefix' => '<div class="textimage-challenge"><img src="' . url('_textimage/image/'.time()) . '" '.$imageSize[3].'  alt="'.t('Captcha Image: you will need to recognize the text in it.').'"/></div>',
      );
    }
    $newform[$name] = $form[$name];
  }
  $form = $newform;
  return $form;
}

I hope this helps you out...

robloach’s picture

Version: 5.x-1.x-dev » 5.x-2.1
Category: support » feature
StatusFileSize
new1.66 KB

The attached is a patch to make it so that you can set the weight of the Captcha form in admin/settings/captcha . All dependant captcha modules have to use variable_get('captcha_weight', 0) for the #weight value when creating the form.

heine’s picture

Status: Needs review » Needs work

FAPI has a weight type, which saves you code.

Setting a weight for all forms is not the solution. Not all submit buttons have the same weight. Some have no weight at all.

wundo’s picture

Status: Needs work » Closed (fixed)