Module looks as though it will be very useful, thanks! I have a longish amount of information text on my site-wide contact page, that is appearing in the contact form block as well. It's not appropriate in the block. Can I suppress it?

Comments

fuerst’s picture

Assigned: Unassigned » fuerst

There are two ways to achieve this:

A) Create a module and use Drupal's hook_form_alter() to modify the form or
B) Register a theming function in the template.php of your theme.

I would prefere A) because it is independent from your theme. If you don't know how to write a module B) is perfect for you. Either way is illustrated for Drupal 6 and 5 in a wonderful article by Addison Berry: http://www.lullabot.com/articles/modifying-forms-5-and-6

Following an example of B) for Drupal 6 to be put in the template.php file of your Theme. Replace yourtheme in the function names by the name of your theme as seen in the folder/directory name of the theme. Don't forget to clear the Drupal Theme Registry by pressing the Clear Cache button in Administer > Settings > Performance (/admin/settings/performance).


/**
* Implementation of hook_theme.
*
* Register custom theme functions.
* 
* Get the ID from the CSS ID of the form. 
* In this example we change the form "contact_mail_page1"
* 
* Note: Change the dashes in the CSS ID to underscores 
* when using in the array key below.
*/
function yourtheme_theme() {
  return array(
    'contact_mail_page1' => array(
      'arguments' => array('form' => NULL),
    ),
  );
}

/**
 * Modify the form with the ID "contact_mail_page1"
 * Get the ID from the CSS ID of the form. 
 * In this example we change the form "contact_mail_page1"
 * 
 * Note: Change the dashes in the CSS ID to underscores 
 * when using in the function name.
 */
function yourtheme_contact_mail_page1($form) {
  // Remove the "Additional information" from the form
  unset($form['contact_information']);
  return drupal_render($form);
}

JulieR’s picture

Thanks, this is very helpful - it's useful to understand both methods. The article looks like just what I need.

Tried out the above code, it works like magic. I look forward to figuring out what it's actually doing.

JulieR’s picture

Status: Active » Closed (fixed)