Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using hook_form_comment_form_alter to add values to the textboxes in the commenting form. But in the comment body I can seem to add a default value and can't seem to find a value that I can change. Does anyone have any ideas?

function mytheme_form_comment_form_alter(&$form, &$form_state, $form_id) {
  $form['author']['name']['#title'] = "";
  $form['author']['name']['#default_value'] = "Name";
  $form['author']['name']['#title'] = "";
  $form['author']['mail']['#default_value'] = "Email";
  $form['author']['mail']['#title'] = "";
  $form['author']['homepage']['#default_value'] = "Website";
  $form['author']['homepage']['#title'] = "";
  $form['author']['subject']['#default_value'] = "Subject";
  //$form['comment_body']['need default value']= 'I need to add a value';
share|improve this question
up vote 3 down vote accepted

To add default value to your comment form body use the following snippet,

 $form['comment_body'][LANGUAGE_NONE][0]['#default_value'] = "Your default value";
share|improve this answer
I think you should use LANGUAGE_NONE constant instead of directly using 'und' – Mathankumar Nov 22 '12 at 9:51
@mathan you re right, i edited my answer – Anoop Joseph Nov 22 '12 at 10:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.