Technical blog and writings by Micah Webner.

Collapse Text format descriptions on node edit form

Collapsed text format fieldset

Ever since migrating to Drupal 7, I've been unable to find a way to collapse the text format tips below a text area. On content types with many text fields, this can be really annoying. It was fairly simple to do this in Drupal 6, but the best I could do in Drupal 7 was hide the tips completely, which isn't really great for users that need them. Until now.

One of the recent usability changes on the issue queues has been to change the text format fieldset to be collapsed by default, by looking at the commit associated with Issue #2104275, I finally saw how to do this using hook_element_info_alter().

The result is a pretty simple change that can be added to a site's custom module.

 * Implements hook_element_info_alter().

function mysite_element_info_alter(&$type) {
  $type['text_format']['#process'][] = 'mysite_element_process_text_format';

 * Process function for text_format element.
 * @see mysite_element_info_alter().
 * @see

function mysite_element_process_text_format($element) {
  $element['format']['#collapsible'] = TRUE;
  $element['format']['#collapsed'] = TRUE;
  $element['format']['#title'] = t('Text formatting help');
  return $element;

In fact, I updated this site while writing this post.

This change looks a little funny in some themes, particularly if you're using the Seven theme as your administration field. Setting a height on the fieldset legend helps.

.text-format-wrapper > fieldset > legend {
  height: 1.25em;

Bonus Hack

Here's a quick bonus hack: While researching this issue, I also found Issue #2127375: Hide 'Revision log message' field on node/add/*, which does exactly what the issue title implies.

 * Implements hook_form_BASE_FORM_ID_alter().

function mysite_form_node_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['revision_information'])) {
    // Hide revision fields on node add form.
    // @see
    // @todo Should be removed in D8 #308820.
    if (!isset($form['#node']->nid)) {
      $form['revision_information']['#access'] = FALSE;

This is a nice cleanup when creating new nodes.