Closed (fixed)
Project:
Webform
Version:
6.x-2.4
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
14 Jan 2009 at 21:33 UTC
Updated:
29 May 2009 at 06:33 UTC
Jump to comment: Most recent
I'd like to theme my webform into two columns: 1st column is the text I enter into "body" of form, the 2nd column would be the form elements to be submitted.
I haven't a clue, so in desperation I tried modifying the webform-form.tpl.php file in ways like below, but obviously nothing has worked so far. Any suggestions?
// Print out the main part of the form.
// Feel free to break this up and move the pieces within the array.
print '<table>';
print '<tr>';
print '<td>';
print $body;
print '</td>';
print '<td>';
print drupal_render($form['submitted']);
print '</td>';
print '</tr>';
print '</table>';
print drupal_render($form);
Comments
Comment #1
somebodysysop commentedWell, actually got a little closer. This prints the form submission elements in one column of the table, but I can't figure out how to get the body into the first column:
print drupal_render($form['submitted']['firstname']);print drupal_render($form['submitted']['last_name']);print drupal_render($form['submitted']['e_mail']);print drupal_render($form['submitted']['telephone']);?>
I've tried all these variations to print the $body:
$form['submitted']['body'];
$form['body']['#value'];
$form['submitted']['body']['#value'];
$node->content['body']['#value'];
$body;
But with no examples, it's pretty hard. HELP!
OK, found the answer to my question:
However, can't drupal_render that:
drupal_render($form['#parameters'][2]->body)throws error. So, if I just print it, the body will show up twice on the form. So, how do I put that body where I want it on the form without it duplicating?Comment #2
quicksketchI think you may be working in the wrong template file. You're wanting to theme the entire node, not just the form. As you've noticed, the body of the node is not available within webform-form.tpl.php.
Instead what you need to do is create a node-webform.tpl.php file. This will contain both the full body and the rendered webform.
Comment #3
somebodysysop commentedThank you so much! That's it: needed to use node-webform.tpl.php.
Comment #4
quicksketchGreat, looks fantastic. :)
Comment #6
glennnz commentedHow would I use this to left align my text fields?
So I would have something like:
Thanks
Glenn
Comment #7
lavanyadotr commentedHave you found out the solution is it is working ?
Comment #8
i.bajrai commentedIf anyone still needs this:
http://drupal.stackexchange.com/a/130796/13971