3

I've tried to preprocess a webform in order to convert the form items into an ordered list. My webform is composed of questions, and I want each question to be a enumerated list element.

enter image description here

The problem is that I cannot find where to convert the <div> following the <form> into an <ol>, and the next nested <div> into an <li>. After navigating webform's source code I could not find a function that says "give me all the webform elements", for example. It all seems to work in the following order:

  • implement hook node load (load webform components)
  • implement hook node view (order webform components into a structure that is hard to modify?)
  • create form
  • render form using some theming functions

When I use the node preprocessor to alter the components (and attempt to insert a #type = item_list somewhere), it doesn't work. And when using one of the webform theming functions, the data structure comes in a way that is hard to modify. Example:

enter image description here

That variable that I tried to modify was the $variables['elements']['webform']['#form']['submitted'] in a hook_preprocess_node.

3 Answers 3

1

Combine the following options

1/ Have a look at the theme functions in webform.module: * webform_element_wrapper * theme_webform_element * theme_webform_element_wrapper

2/ Make use of webform.tpl.php

Or try with jquery/css to alter the whole structure

1

Install Theme Developer and look for theming function name.

1
  • The second image in the question is from the variables in the theming function. Commented Jul 27, 2011 at 20:25
1

If you just want it to look like a list, you can use css to style it.

#webform-client-form-70 .form-item {
  display: list-item;
  list-style-type: decimal;//for ordered list appearance 
}  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.