I am seeing an issue where the captcha is placed below the form submit button using Captcha 6.x-2.1 with Webform 6.x-3.0-beta5.

This problem was also noted in a different issue here: http://drupal.org/node/735202#comment-2786900

Thanks for any help you can provide.

Comments

debbo1977’s picture

Hi, did you add the captcha in through the webform or whist viewing the form?

i.e did you go to form components when creating the form and choose captcha there,
or did you view the form live and choose the "insert captcha..." drop down from there?

jwinton’s picture

The captcha was added through the Captcha module general settings by entering the form ID and selecting the challenge type.

This method worked great with Webform 2.0 -- should I be going another route with Webform 3?

Thanks!

louiswolf’s picture

The placement of the captcha element is determined by its 'weight'.
In captcha.inc the weight of the captcha element is determined by the weight of the preview button (20) and is set 0.1 lower (19.9). However, the weight of the submit button (19) is not taken into account so the CAPTCHA block ends up between these buttons (19 < 19.9 < 20).

captcha.inc can be adjusted so set the weight 1.1 lower (instead of 0.1), thus placing the CAPTCHA element before the submit button.

line 315:
$captcha_element['#weight'] = $target_weight - 1.1;

jwinton’s picture

Thanks for the response. I tried making that change to captcha.inc and, unfortunately, it did not seem to make a difference. I also tried clearing cache, removing and then re-adding the captcha to the form, but no luck. Did this work for you?

luthien’s picture

It worked well for me, add the fix here:

// If no target is available: just append the CAPTCHA element to the container.
  if ($target_key == NULL || !array_key_exists($target_key, $form_stepper)) {
    // Optionally, set weight of CAPTCHA element.
    if ($target_weight != NULL) {
      $captcha_element['#weight'] = $target_weight - 1.1;
    }
    $form_stepper['captcha'] =  $captcha_element;
  }
jwinton’s picture

Status: Active » Closed (fixed)

Thanks! That worked for me.

Changing the line at 315 did not work for me, but the changes to line 306 that you posted did the trick.

jmbarlow’s picture

Perfect - that solves it for me.

sun’s picture

Version: 6.x-3.0-beta5 » 7.x-3.x-dev
Component: User interface » Code
Status: Closed (fixed) » Needs review
StatusFileSize
new692 bytes

Re-opening due to #830228: Weights of submit buttons of webforms are not modified

To begin with HEAD/D7, all buttons in all forms are supposed to be contained in a #type 'actions' element.

quicksketch’s picture

Do #type = 'actions' already have a default weight? What makes them show up at the bottom of a form?

sun’s picture

quicksketch’s picture

Weight 100 might not be enough on a really big form, I've seen forms with hundreds of components and it'd make me a little easier if we just kicked it down to 1000 like it is now.

sun’s picture

StatusFileSize
new692 bytes

If that's the case, then we can surely set a custom, higher weight.

quicksketch’s picture

Super, while this looks like a no-brainier fix for D7, what's the solution for D6?

sun’s picture

For D6, I suggest to go with a Mollom-only fix, since you prepared Webform on D7 standards already - as propatched in #830228-5: Weights of submit buttons of webforms are not modified

quicksketch’s picture

Status: Needs review » Fixed

Thanks, #12 committed to the D7 branch..

Status: Fixed » Closed (fixed)

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