Drupal creating a template for an existing form

In this example, I add a template in a custom module for the print_mail_form that comes with the print module

in mymodule.module:

 * Implements hook_theme().  
function mymodule_theme($existing, $type, $theme, $path) {
  return array(
    'mymodule_print_mail_form' => array(
      'render element' => 'form',
      'template' => 'mymodule-print-mail-form',
 * Implements hook_form_FORM_ID_alter().
function mymodule_form_print_mail_form_alter(&$form, &$form_state, $form_id) {
  $form['#theme'] = 'mymodule_print_mail_form';

in mymodule-print-mail-form.tpl.php

<h1>My Custom Print Mail Form is soooo RAD.</h1>
// render the name and address fields out of order
print render($form['fld_from_name']);
print render($form['fld_from_addr']);
// print the rest of the fields - this has to be here for the form to work.
print drupal_render_children($form);


Internal References

Article Type