Hi,

I created my first module today and like magic, the code below changes the value of the save button on a comment form to Add. How can I change it to change the value of the "Add New Comment" to a SPECIFIC content type to something else.

// $Id$

function ModuleName_form_alter(&$form, $form_state, $form_id) {
if($form_id == 'comment_form') {
$form['submit']['#value'] = 'Add';
}
}

Thanks in advance

Comments

graysadler’s picture

Load the node from $form['nid'] and check the $node->type.

function ModuleName_form_alter(&$form, $form_state, $form_id) {
  if($form_id == 'comment_form') {
    $node = node_load($form['nid']);
    if($node->type == 'content_type_name_here') {
      $form['submit']['#value'] = 'Add';
    }
  }
}

Lead Developer and Founder of StreamRiot.com

WorldFallz’s picture

'add new comment' appears on the viewed node-- i think you want http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hoo...