0

I have tried a number of different modules that claim to do this but none have worked, I have also tried changing the comment.tpl file, and I even tried using CSS "Display:none"; however nothing has worked. So how can I hide the "Comment" label on a comment form box? I am not talking about the comment title here, as this can be easily disabled in the content type settings. This is what I am talking about: enter image description here

I originally thought that this could be done in the manage display settings, by setting the comment label to hidden. So I did this but it didn't change the label of the comment box: enter image description here

So how can this be done? I simply want to hide the word "Comment" and the "*" after it of course.

enter image description here

1

You can easily do this with CSS. Looking at dev tools, I see that the label is called edit-comment-body-und-0-value (yours might be different). So what we need to do is, simply edit the CSS file and put in the line label[for*="edit-comment-body-und-"] { display:none; } and clear the cache at /admin/config/development/performance.

That's all there is to it.

K.

| improve this answer | |
  • I have tried using CSS however it doesn't hide it unfortunately. The only way I have managed to get close with CSS is to use the "label" tag (since the Comment is a label) and setting it to display none, however this affects ALL labels which is not ideal. If it works for you, could you post a screenshot because as I said I cannot get it to work using CSS classes/ids. I am using D7 by the way. – FrontEnd Jun 22 '14 at 11:21
  • @FrontEnd I tried again at my own end, and edited my answer accordingly. – Kartagis Jun 22 '14 at 11:50
  • Thanks for that Kartagis, the problem though is that each comment box label uses a different label name. I've added a screenshot in my question showing the label name using Firebug. The problem is that the label name automatically adds "--#" at the end of the label name, so the first node comment box label will be "edit-comment-body-und-0-value", the next will be "edit-comment-body-und-0-value--1" then "edit-comment-body-und-0-value--2" and so on. This makes it impossible to use CSS because you have to add more CSS whenever a new node is created. – FrontEnd Jun 22 '14 at 12:14
  • If I apply CSS to "edit-comment-body-und-0-value" it will only hide the first comment box's label and the rest of the label show. Any ideas how this can be solved? – FrontEnd Jun 22 '14 at 12:15
  • 1
    @FrontEnd I edited my answer again :) – Kartagis Jun 22 '14 at 13:51
0
 /* Remove the "your name" elements for authenticated users */
function YOURTHEME_form_comment_form_alter(&$form, &$form_state) {
if ($form['is_anonymous']['#value'] == false) {
$form['author']['#access'] = FALSE;
$form['comment_body']['und']['0']['#title'] = FALSE; //Remove the user name
$form['comment_body']['und']['0']['#title'] = FALSE;
$form['comment_body']['und'][0]['#required'] = FALSE;
 }
}
| improve this answer | |
  • If it provides an answer to the question. please add some description to your answer – Krishna Mohan Nov 5 '14 at 4:43

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.