Simple Site-wide Contact Form

Posted by Lucas Hedding on April 3, 2013
Development
Strategy & Architecture

If you want a real simple site contact form without a lot of extra work, here's something to try on for size.  Form fields shouldn't really be unset, so just hide them. I don't really want the site visitor to set the "category", so that gets hidden.  I also decided that I want to always send a copy of the contact back to the requester, so I set the default value for the second field and hide it as well.

/**
 * Implements hook_form_FORM_ID_alter().
 */
function example_form_contact_site_form_alter(&$form, &$form_state, $form_id) {
  $form['cid']['#access'] = FALSE;
  $form['copy']['#access'] = FALSE;
  $form['copy']['#default_value'] = TRUE;
}

 

Do you need help designing your Drupal site? We can work with you to create a professional, scalable and high-performing site that meets the unique user and technology needs of your business.

Write us about your project, and we’ll get back to you within 48 hours.


Simple Site-wide Contact Form