Remove 'Preview' button in Drupal 6 comment form

Mar 14 2011

By default in Drupal 6, there is a 'Preview' button in addition to a 'Save' button in the form which allows a user to post a comment. For those of us who think it is silly to have a preview before posting, the good news is that you can remove the button quite simply with a bit of code.

Place the following code in the template.php file which exists in the directory for the theme that you are using. If your theme does not use a template.php file, go ahead and create one.

This code goes in template.php:

<?php
 
function comment_form_comment_form_alter(&$form, $form_state)
{
  unset($form['preview']);
}
 
?>

Of course, only one set of start and end tags should be in your template.php file, so omit <?php and ?> if necessary.

Remember to clear your cache for the changes to take effect. You should now be rid of the 'Preview' button on comment forms.

We hope this tutorial was helpful.

No votes yet


Drupal user said:

Apr 6, 2011 at 5:32 am

Useful blog on Drupal 6! Thanks for the code reference......

Post new comment

The content of this field is kept private and will not be shown publicly.
Image CAPTCHA
Enter the characters shown in the image.
Link to this Page