Posted by TWagner on January 13, 2012 at 4:58am
2 followers
| Project: | CAPTCHA |
| Version: | 6.x-2.4 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I enabled captcha for a new form and initially, it worked correctly. However, when the production database was loaded, the captcha would up being placed BELOW the submit element. This was NOT a CSS issue; the div was actually placed in the wrong order.
I tried taking the submit button out, clearing caches, re-enabling the submit function... nothing worked. When captcha came back back, was always below the submit element in the form array.
The hack: disabled the captcha for the form_id in question (by going to /admin/user/captcha).
Then, hand coded the captcha element into the form by hand (see http://drupal.org/node/743056)
<?php
$form['activate_captcha'] = array(
'#type' => 'captcha',
);
?>Worked. Nonetheless, this is a bug.
Comments
#1
I understand it is a custom form, is that correct?
can you provide the form source code?
If you talk about clearing caches, which caches are that? Standard drupal caches? Or the captcha placement cache?
#2
With reference to clearing caches, I cleared both standard Drupal cache and captcha placement cache.
Here is the custom form code (with the hand coded call
function activate_id_form($form_state) {
$path = drupal_get_path('module', 'activate_id');
$tag_exmpl_path = $path . PET_TAG_PIC;
$button_path = $path . '/images/activate_button.png';
$pet_id = $GLOBALS['pet_id'];
$node_object = node_load($pet_id);
$pet_name = $node_object->title;
$GLOBALS['pet_name'] = $pet_name;
$logged = $GLOBALS['user']->uid;
.
.
.
$pic_path = $node_object->field_pet_mainpic[0]['filepath'];
//$pic_path = theme('imagecache', 'pet-pic-profile', $pic_path);
$greeting = 'Activate your pet tag for ' . $pet_name;
$form['greeting'] = array(
'#value' => "<p class=\"greeting\"><h1>{$greeting}</h1></p>",
);
$form['features'] = array(
'#prefix' => '<div id="petmugshot" class="field-pet-mainpic">',
'#suffix' => '</div>',
'#value' => theme('imagecache', 'pet-pic-petcard', $pic_path),
);
$form['tagtext'] = array(
'#prefix' => '<div id="directions">',
'#suffix' => '</div>',
'#value' => t('<p> The Tag ID is the last part of the web address.
<span style="color:#F90">ABC123</span>,
then enter <span style="color:#F90">ABC123</span> as the Tag ID.</p>'),
);
$form['tagexmpl'] = array(
'#prefix' => '<div id="example_tag">',
'#suffix' => '</div>',
'#value' => t('<img src="/' . $tag_exmpl_path . '" class="field-pet-tagexmpl" name="features" width="160" height="160" id="petexmpl"/>'),
);
$form['petpictxt'] = array(
'#prefix' => '<div id="petpic_foot">',
'#suffix' => '</div>',
'#value' => t('This will activate the specified tag for <strong> %pet </strong>', array('%pet' => $pet_name)),
);
$form['tag_id'] = array(
'#type' => 'textfield',
'#title' => 'Tag Id',
'#description' => l('Oops! Wrong Pet?'),
'#size' => 40,
'#maxlength' => 60,
'#required' => TRUE,
);
//Hand coding the captcha into the this form because the automatic placement is putting this BELOW the submit element.
$form['activate_captcha'] = array(
'#prefix' => '<div id="recaptcha_box">',
'#suffix' => '</div>',
'#type' => 'captcha',
);
$form['submit'] = array(
'#prefix' => '<div id="submit">',
'#suffix' => '</div>',
'#type' => 'image_button',
'#attributes' => array('id' => 'submit_tag'),
'#src' => $button_path,
'#submit' => array('activate_id_form_submit'),
);
return $form;
}
#3
is it only the CAPTCHA element that is in an undesired place, or are there other things in an other order than in source code?
can you provide a screen shot of the resulting form?
#4
It is only the CAPTCHA element that winds up at the bottom, regardless of where it is placed in the code.
Screen shot attached.