New comment altering module

Events happening in the community are now at Drupal community events on www.drupal.org.
samwillc's picture

Hi everyone,

Ok, totally irrelevant post but have to share! I made a module and it actually does something, sorry if the post title suggests way more brilliance than what it actually does.

I wanted to change the button text on the comments form on my site (why does it say 'Save' anyway?!) so I made a little module (custom_comments.module and an .info file as per instructions) with the following in it:

<?php
function custom_theme_form_comment_node_blog_post_form_alter(&$form, &$form_state) {
$form['actions']['submit']['#value'] = 'Post a new comment';
}
?>

Enabled the module, went to my blog, and looked in amazement as the button now says 'Post a new comment'. And it works. Probably not even the right way to do it but I'm so pleased anyway! It's on my test site btw. Ok, so it's pretty lame, and allows no customization, and only works if your form is called comment_node_blog_post, lol, but Rome wasn't built in a day! I'd love to extend it so it has a config screen that a user could choose which form to alter, and what text to use for the button, but no idea how to do that yet. Maybe need to make the form name and the submit value a variable which will populate depending on the users choice via the drupal UI.

I'm sure even the most hardened coders remember the first time they did some code (however small) that actually did something! :)

Baby steps, baby steps...

Sam.

Omega Framework

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: