Skip to main content
Aug
29
2011

Drupal 7 notes: unsetting formatting tips

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).

Feb
11
2011

Drupal 7 notes - Hiding unwanted form elements in comment forms

Just so I don't drive myself completely insane again.

It's a fairly standard theming problem, you have your Drupal comment form rendering thusly:

Drupal comment form (in WANLN theme)

Your site is set to not allow posting by anonymous users, rendering the "Your name" field superfluous and you think the subject line looks ugly, is unnecessary or you just don't want users giving their comments subjects for whatever reason.

In Drupal 6, you do it like this.  In Drupal 7, it's easier but harder to find.  They're in the docs, but the docs are a bit of a mess still.