Drupal Simplified Contact Form

Drupal Simplified Contact Form

Hold on Cowboy

This blog post is pretty old. Be careful with the information you find in here. It's likely dead, dying, or wildly inaccurate.

A site I’m working on has a simple contact us form in the footer of every page. I didn’t want the long drawn out contact form with all the name, subject, email, message fields. Here is what I did.

Installed the formblock module

Easy enough, install the module, enable the block so that the contact form now shows in the footer.

Simplify the contact form

Now we want to hide some of the fields in the contact form.

In your template.php file, you’ll want to add the following lines.

<php>
function basic_theme(){
  return array(
    'contact_mail_page' => array(
      'arguments' => array('form' => NULL)
      )
    );
}

/**
 *  Hide and autofill some fields in the contact form.
 *
 */

function basic_contact_mail_page($form){

  $form['subject']['#value'] = "Website question";
  $form['subject']['#type'] = 'hidden';
  $form['name']['#type'] = 'hidden';
  $form['name']['#value'] = 'Website Customer';
  return drupal_render($form);
}
</php>

As you can see I’m using the Basic theme from Drupal. If you’re using a different theme you’ll want to change the word basic to your own theme (e.g. blueprint).

Now you have a simple contact form.

drupalcontact.png