Hi,
First of all am a newbie. So if my questions sound stupid they may be stupid. I have done lot of RTFM and googling but failed. I have 3 problems, all related to themes. First one is I need to theme a webform. I have read the webform readme files and they said:


Theming a webform can be useful for rearranging elements or customizing the
appearance of multiple components at once. This tutorial assumes usage
of the phptemplate engine.

- Open your template.php file located in your theme's directory.
- Add the following lines of php code:

function phptemplate_webform_form_[node id here] ($form) {
return _phptemplate_callback('webform_form_[node id here]', array('form' => $form));
}

- Replace "[node id here]" with the node ID of the form.

- Create a new file in your theme's directory named
"webform-form-[node id here].tpl.php", once again replacing [node id here]
with the node ID of the webform.

- Open up your new file and customize the webform however you like. Here's an
example putting a field with the "email" key inside of another fieldset.

  // Create a new fieldset within the main fieldset
  // Note: All fields MUST stay within the 'submitted' fieldset
  $form['submitted']['newfieldset'] = array(
    '#type' => 'fieldset',
  );
  
  // Move the form field labeled "email" to the new fieldset
  $form['submitted']['newfieldset']['email'] = $form['submitted']['email'];
  unset($form['submitted']['email']);
  print drupal_render($form);

So accordingly I created a file named "webform_form_10.tpl.php" and placed following code in the file


$form['submitted']['name']['Name'] = $form['submitted']['whats your name'];
unset($form['submitted']['Name']);
$form['submitted']['email']['Email'] = $form['submitted']['and email'];
unset($form['submitted']['Email']);


echo drupal_render($form);

Added following function to the template.php file

function phptemplate_webform_form_10 ($form) {
  return _phptemplate_callback('webform_form_10', array('form' => $form));
}

Nothing ever happened and I dont know why, for the sake of clarity, I am using garland theme.

Any help?

Comments

alan d.’s picture

I can not comment on the theming function, but did you flush the cache after creating the new files/hooks?

If not, flush this and try again.

If you do not know how, install Devel, assign permissions to your super user role, enable the devel block, and you'll have a nice "flush cache" link in the block. You'll also get a huge range of devel tools, including the theme developer. This is pure gold for any Drupal themer, especially newbees. :)


Alan Davison
www.caignwebs.com.au

Alan Davison
kumarldh’s picture

I have disabled cache, also I have read the documentation again and it seems that some of the functions are not available in D6
Duh!

Why is drupal so hard to learn?

fumanchu182’s picture

The reason the $form element is not accessed is because all *.tpl.php files deal directly with the node content, not form content. I am working on a solution that intercepts the form_id at the hook_form_alter() level and then applies the theme. So far as I can tell digging into the webform modules is that a form is built in a non standard way. Whenever you hit hook_form_alter() and apply $form['#theme'] since it is node content it never displays the theme on the form.

This is my .02 cents.

Anthony Wlodarski
PHP/MySQL Developer
www.thrillist.com
560 Broadway, Suite 308
New York, NY 10012
p 646.274.2435
f 646.557.0803

Phil.Hersh’s picture

Hi Kumar,

This example will only do something if you have a field that has the key email.