technonaturalist

image link to hive image link to ko-fi

Drupal 7 notes: unsetting formatting tips

posted on: Monday, 29 August 2011 @ 1:22pm in
tagged

Following on from hiding unwanted elements in comment forms, I found this tip on one of the many threads in Drupal of people trying to hide the pesky formatting guidelines and came up with:

template.php

<?php
  function [theme_name]_form_comment_form_alter(&$form, &$form_state, $form_id)
  {
    $form['comment_body']['#after_build'][] = 'remove_tips';
  }
  
  function remove_tips(&$form)
  {
    unset($form['und'][0]['format']['guidelines']);
    unset($form['und'][0]['format']['help']);
    return $form;
  }
?>

That gets rid of everything but the fieldset container and for the roles that can use multiple text formats, the select box (the “Text format” label can be easily removed with $form['und'][0]['format']['format']['#title'] = ''; in the comment_form_alter).

I haven’t worked out a way to unset or otherwise prevent the select box from rendering without obliterating TinyMCE, so will have to continue letting display: none; on .filter-wrapper hide it for now :)