Altering the Site Wide Contact Form

If you already have a custom theme or module installed, then, theming the site-wide contact form becomes extremely easy. One little alter function, and that's it! You are ready to go. For our example here, let's say you want to add an extra field to the contact form and change the text of the submit button. So, we've got two alternatives here, hook_form_alter() or hook_form_FORM_ID_alter(). We'll use the hook_form_FORM_ID_alter() function for this case. Now, since I've got my own custom theme, I'll add this function to template.php in my custom theme

* Implements hook_form_contact_site_form_alter().
* This will add an extra textfield and change the value of the submit button
* by implementing hook_form_FORM_ID_alter().
function yourcustomtheme_form_contact_site_form_alter(&$form, &$form_state, $form_id) {
  //Change the text of the submit button
  $form['actions']['submit']['#value'] = t('Go!');
  //Add an extra textfield to store the phone number
  $form['phone_number'] = array(
      '#type' => 'textfield',
      '#description' => t('Enter your business phone number'),
      '#title' => t('Phone'),
      '#default_value' => '',
  //Style the message textarea differently by adding another class
  $form['message']['#prefix'] = '<div id="contact_us_message">';
  $form['message']['#suffix'] = </div>';

And, that's it! You've got an extra textfield, a submit button that say's "Go!", and a new class for the message area so you can style it the way you want.