主题化Web-Form

This is one of the finest technique I found so far to theme webform form. In fact, it could be used for any form generated through Drupal FORM API.

For Example, I needed certain elements of the form to be on one line (horizontally placed), I could do something like below. This is just override function of "template_preprocess_webform_form" provided by webform module. Place this in your theme's template.php file.

function garland_preprocess_webform_form(&amp;$vars) {<br />
&nbsp; drupal_add_css(drupal_get_path(&#39;module&#39;, &#39;webform&#39;) . &#39;/css/webform.css&#39;);<br />
&nbsp; drupal_add_js(drupal_get_path(&#39;module&#39;, &#39;webform&#39;) . &#39;/js/webform.js&#39;);<br />
&nbsp;<br />
&nbsp; $vars[&#39;form&#39;][&#39;submitted&#39;][&#39;name&#39;][&#39;#prefix&#39;] = &#39;&lt;table border=&quot;0&quot;&gt;&lt;tbody style=&quot;border: 0px;&quot;&gt;&lt;tr&gt;&lt;td&gt;&#39;;<br />
&nbsp; $vars[&#39;form&#39;][&#39;submitted&#39;][&#39;name&#39;][&#39;#suffix&#39;] = &#39;&lt;/td&gt;&#39;;<br />
&nbsp; $vars[&#39;form&#39;][&#39;submitted&#39;][&#39;phone&#39;][&#39;#prefix&#39;] = &#39;&lt;td&gt;&#39;;<br />
&nbsp; $vars[&#39;form&#39;][&#39;submitted&#39;][&#39;phone&#39;][&#39;#suffix&#39;] = &#39;&lt;/td&gt;&#39;;<br />
&nbsp; $vars[&#39;form&#39;][&#39;submitted&#39;][&#39;city&#39;][&#39;#prefix&#39;] = &#39;&lt;td&gt;&#39;;<br />
&nbsp; $vars[&#39;form&#39;][&#39;submitted&#39;][&#39;city&#39;][&#39;#suffix&#39;] = &#39;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&#39;;<br />
<br />
&nbsp; if (isset($vars[&#39;form&#39;][&#39;details&#39;][&#39;nid&#39;][&#39;#value&#39;])) {<br />
&nbsp;&nbsp;&nbsp; $vars[&#39;nid&#39;] = $vars[&#39;form&#39;][&#39;details&#39;][&#39;nid&#39;][&#39;#value&#39;];<br />
&nbsp; }<br />
&nbsp; elseif (isset($vars[&#39;form&#39;][&#39;submission&#39;][&#39;#value&#39;])) {<br />
&nbsp;&nbsp;&nbsp; $vars[&#39;nid&#39;] = $vars[&#39;form&#39;][&#39;submission&#39;][&#39;#value&#39;]-&gt;nid;<br />
&nbsp; }<br />
}

That's it! You could do almost anything you want with this technique!