By Fero


2013-05-21 12:03:38 8 Comments

I am in need to theme webform in D7.

How can I do that ?

In the search I've come to know that by using web-form-nid.tpl.php we are able to theme a drupal individual form.

Could any one guide me in this case to theme a webform.

2 comments

@Anoop Joseph 2013-05-21 12:14:58

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

@Matt Saunders 2015-12-23 17:35:59

I can't figure out how to render the submit button, please can you help

@Anoop Joseph 2015-12-29 06:11:51

Can you specify what have been you tried so far and where you struck at? The submit button can render by something like this <?php print render(drupal_render($form['submit'])); ?> Do a print_r($form); for better understanding.

@ProGrammar 2017-03-10 21:09:05

Or, alternatively, to render submit, you can just do: <?php print drupal_render_children($form); ?>. It will render everything else that you haven't specifically rendered, which for my form I'm working on now is just the submit button.

@Mołot 2013-05-21 12:10:13

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!

Related Questions

Sponsored Content

0 Answered Questions

Display a user's responses to a webform in the webform but uneditable

  • 2019-02-15 08:38:51
  • Adaddinsane
  • 20 View
  • 2 Score
  • 0 Answer
  • Tags:   8 webforms

1 Answered Questions

[SOLVED] How to theme webform in D6?

  • 2012-06-27 13:36:14
  • Dude
  • 627 View
  • 0 Score
  • 1 Answer
  • Tags:   6 theming webforms

0 Answered Questions

Webform CiviCRM Contribution Fails

  • 2014-11-21 17:25:53
  • Shai
  • 150 View
  • 1 Score
  • 0 Answer
  • Tags:   civicrm webforms

3 Answered Questions

[SOLVED] styling webform into 2 columns

  • 2014-01-21 20:13:45
  • scapegoat17
  • 3764 View
  • 0 Score
  • 3 Answer
  • Tags:   7 theming webforms

1 Answered Questions

[SOLVED] Create a new user on Webform submission

  • 2017-08-14 10:27:11
  • FrankDesign
  • 424 View
  • 0 Score
  • 1 Answer
  • Tags:   webforms

1 Answered Questions

2 Answered Questions

[SOLVED] How to remove the webform title field on add/edit form?

  • 2015-08-16 22:57:58
  • learn4ever
  • 1333 View
  • 0 Score
  • 2 Answer
  • Tags:   webforms

1 Answered Questions

Theme webform using custom module

  • 2014-08-16 16:24:27
  • joejam
  • 127 View
  • 0 Score
  • 1 Answer
  • Tags:   hooks webforms

2 Answered Questions

[SOLVED] Editable webform submissions

  • 2013-09-09 19:08:21
  • Petr Felzmann
  • 790 View
  • 1 Score
  • 2 Answer
  • Tags:   webforms

0 Answered Questions

how to theme a GROUP of webforms?

Sponsored Content