I wrote this as I felt that the instructions for theming webforms was a little vague and confusing. It might just have been me, but maybe this will help someone else - I can't be the only confused person out there....can I? :) So here goes....
We can use theming to add CSS id's and classes to webforms. There are two methods available, each have their own advantages.
Method 1
- Pros:
- can create new fieldsets easily without re-doing the webform
- can add any html code you before and after the fieldsets
- Cons:
- two files to edit
Add the following code to your template.php file to redirect processing to your own template file:
//change the number here '123' to the id number of your webform
function phptemplate_webform_form_123 ($form) {
return _phptemplate_callback('webform_form_123', array('form' => $form));
}
Then create the file you mentioned in the callback statement above. In this case its called webform_form_123.tpl.php
. Now you can create fieldsets and add your own CSS id's or classes to them, using the prefix and suffix attributes to add a new div (you can put anything you want here):
<?php
$form['submitted']['fluentin'] = array(
'#type' => 'fieldset',
'#prefix' => '
',
'#suffix' => '
',
'#weight' => -1,