Drupal - How do I theme a webform?

You can theme a individual webform using webform-form-nid.tpl.php.

For example if our webform node id is 7 , create a template file namely webform-form-7.tpl.php and place it in your theme folder. Clear site cache.

Do a print_r($form); to see all the elements. Then render each elements in file within your html elements.

<li>
    <?php print drupal_render($form['submitted']['name']); ?>
</li>

As @Patrick Kenny said read the theming.txt, it explain all aspects of theming a webform


If you know the .tpl.php filename, here is what you do:

  • Create empty file with that name in your theme. Element it was supposed to template disappeared? Good.
  • Put simple html tag and see if it is displayed in place of your element. It is? Great, you have correct template file.
  • See all variables you can use: place <pre><?php print_r(get_defined_vars()); ?></pre> in your template.
  • Now when you have a file and data structure, just do it!