1

using Drupal 7, I'd like to add some help text underneath each field for the user who is filling out the comment for a node.

For example, under 'your name' I'd like it to say, possibly in smaller font, "only give your name if you want it published with your comment".

Anyone know how to do this (maybe with hook_form_alter)?

2

I think in hook_form_alter, you need to check the $form_id first, so that you can target comment form. If it is a comment form, then you need to add description for the field you want. Just like this

function hook_form_alter(&$form, &$form_state, $form_id) {

$form['name']['#description'] = t('Me help text'),

}

2

Or just edit comment.tpl.php in your template files. Copy comment.tpl.php to your template folder and if not present in the code, add $author name and desired text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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