captcha shows up after submit button

Another issue with the drupal contact form.

The catpcha image and input field show up after the "Send e-mail" button.

Average: 3.2 (169 votes)

Duplicate of

Duplicate of http://heine.familiedeelstra.com/node/37.

The issue here is that the contact form submit button doesn't have a weight. It is clear that MyCaptcha needs to solve this a bit more intelligently.

In the mean time you can fix Captcha appearance on the contact form in your theme: Create or add to the file template.php (minus <?php ?> tags):

  1. function phptemplate_contact_mail_page($form) {
  2.   $button = drupal_render($form['submit']);
  3.   return drupal_render($form) . $button;
  4. }

Works great!

Thank you so much - this fix works!

I just added more instances of that code for the other MyCaptchas on my sites (i.e. I have the Postcard module on one of my sites), changing contact_mail_page to the name of the form (i.e. postcard_create_form).

Another example

You are welcome.

Some forms need a slightly different treatment as their submit button is named differently (internally). This is the case for guestbook for example:

  1. function phptemplate_guestbook_form_entry_form($form) {
  2. //function theme_guestbook_form_entry_form($form) {
  3.   $output = '';
  4.   $access = $form['access']['#value'];
  5.   $display = $form['display']['#value'];
  6.   $uid = $form['uid']['#value'];
  7.  
  8.   switch ($access) {
  9.     case 'allowed':
  10.       if ($display == 'link') {
  11.         // output only a link to a page with the form
  12.         $output .= '<p>&raquo; '. l(t('Add guestbook entry'), "guestbook/$uid/form") .'</p>';
  13.       }
  14.       else {
  15.         $output .= $display == 'page' ? '' : '<h3>'. t('Add guestbook entry') .'</h3>';
  16. // CHANGED:
  17.         $button = drupal_render($form['send']);        
  18.         $output .= drupal_render($form) . $button;
  19.       }
  20.       break;
  21.     case 'own guestbook':
  22.       $output .= ' ';    
  23.       break;
  24.     case 'not logged in':
  25.       $output .= '<p class="links">&raquo; '. t('You must be logged in to post a comment.') .'</p>';
  26.       break;  
  27.     case 'not allowed':
  28.       $output .= '<p class="links">&raquo; '. t('You are not allowed to post in this guestbook.') .'</p>';
  29.       break;  
  30.   }
  31.   return $output;
  32. }

into documention you go!

This neat trick should really be mentioned in the documentation!
This is the second time I stumble across this (first time I didn't solve it :-)

Great module!