5

How do I remove the input formatting options and descriptions from the comment form?

I'm not interested in a CSS and/or jquery based solution, nor am I interested in using the Better Formats module, as I am using Drupal 7 and it specifically states it is not ready for production sites (besides the fact installing a module to do this seems like overkill). I want the html sent over the wire to not have the "input format" related text at all.

Drupal drives me nuts sometimes, because some stuff that should be simple is ridiculously complex.

I've searched but no one seems to know how to do this. Here's some things I've found:

  • Drupal is well Drupal.. – kratos Mar 3 '16 at 17:28
16

Ok found this drupal issue discussing the matter: Node and Comment Input Format fieldset is not working (I found it by searching for "edit-comment-body-und-0-format" which html id of the fieldset that contains all the input format mumbo jumbo).

At the end of this issue is a link to the following site which gives a solution: How To Remove Format Options / Guideliness From Comments Textarea in Drupal 7.

Here's the code I'm using on my site, in template.php of my theme (I'm using a zen subtheme):

function mytheme_form_comment_form_alter(&$form, &$form_state) {

  $form['comment_body']['#after_build'][] = 'mytheme_customize_comment_form';

}

function mytheme_customize_comment_form(&$form) {
  $form[LANGUAGE_NONE][0]['format']['#access'] = FALSE;
  return $form;
}

I just tried it and it does seem to be working. Woohoo!

  • very well. In the past I have used css on my site to hide the options – uwe Jan 2 '12 at 3:02
  • 1
    it should be noted that this (['format']['#access'] = FALSE) disables the Wysiwyg editor – batigolix Jan 6 '14 at 15:06
  • @batibolix: for me it not just disables Wysiwyg editor, it also shows warning messages like "Undefined index: format in wysiwyg_pre_render_text_format" in wysiwyg module. Removing items from #pre_render array solves my problem – tomas.teicher Apr 27 '14 at 18:18
3

Check this module https://drupal.org/project/simplify .

From the module's project page:

Simplify allows particular fields to be hidden from the user interface. This helps to de-clutter forms and present a more user-friendly experience to content editors.

Very helpful to hide unnecessary tips and text format option under RTE

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.