I used following code to create a module to remove input format from comment forms, but it doesn't work. Is there anything I'm missing or another way to do this ?

function comment_custom_form_alter($form, $form_state, $form_id) {
  if ($form_id == 'comment_form') {
    foreach ($form['comment_filter']['format'] as $i => $filter) {
      if (is_int($i) && !$filter['#type']) {
        $form['comment_filter']['format'][$i]['#value'] = '';
        $form['comment_filter']['format'] = '';
Administer > Site Configuration > Input Formats

Click configure for each of the formats, and edit which roles can see which format.

You can also look at Better Formats.

Set the default format per role. Set the default format per content type. Control allowed formats per content type. Hide format tips. Hide more format tips link. Hide format selection for nodes, comments, and blocks seperately, forcing the default to be used. Expand the selection fieldset by default. Disable the expand/collapse of the selection fieldset. Set selection fieldset title. Set more format tips link text. Set default formats for nodes and comments separately. Sensible defaults and fail overs for ease of use. Works with CCK textareas. Works with Panels comment form. i18n module support for user defined strings


Also if you want to hide it completely you can also unset the filter form element in your form alter but I don't think it is the right way to do it.


NOTE: If you do so you will loose out on text processing and checks which drupal makes to make sure the html is safe.

This should also work

$form['comment_filter']['format']['#access'] = FALSE;

This will make sure the format is not accessing to anyone.

Try this

function modulename_form_alter(&$form, &$form_state, $form_id) {
 if ($form_id == 'comment_form') {
  $form['comment_filter']['format']['#access'] = FALSE;
| improve this answer | |
  • Thank you, I want to completely remove input format. If I do as you say admin still can see the input format. any ideas ? – Zim3r Nov 5 '12 at 17:45
  • 1
    well, admin will always see everything and this is how it should be. You can create a different role called "Administrator" and give appropriate permissions – Marius Ilie Nov 5 '12 at 17:59
  • 1
    @Jake you can always use #access property to hide it from admin as well :). Hope it helps. – junedkazi Nov 5 '12 at 18:00
  • 1
    @Jake you need to do this in the form alter in your module file. – junedkazi Nov 5 '12 at 18:09
  • 1
    @Jake try the code I have updated in my answer. replace modulename with the name of the module. – junedkazi Nov 5 '12 at 18:33

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.