Theming forms
ponkarthik - March 31, 2008 - 18:38
Hi,
Can anyone let me know how to pass additional variables to theme function for a form in Drupal 6 ?
I am converting a module from 5.x to 6.0 and am stuck with theming multistep form. I was previously using a hidden element $form['step'] to keep track of the form step in the theming function. In Drupal 6 I have done away with the hidden element and am using a $form_state['storage']['step'] variable . But I am not able to access the $form_state['storage'] inside the theme function even if I pass it as a parameter ?
// theme registering
function module_theme(){
return array(
'dasap_formz' => array('arguments' => array('form','form_state'))
);
}
function module_formz($form_state){
if(!isset($form_state['storage']['step'])){
$form_state['storage']['step']=1;
}
switch ($form_state['storage']['step'])
{
case 1:
..........
case 2:
..........
}
}
function theme_module_formz($form,$form_state){
switch ($form_state['storage']['step'])
{
case 1:
..........
case 2:
..........
}
}I get this error
warning: Missing argument 2 for theme_dasap_formz() in /..../modules/dasap/dasap.module on line 656.
I have tried passing other global variables to pass on the value of 'step' but I always get this same above error.
Any help will be appreciated
Regards
Karthik

Any Solution ?
Did you find any solution of this problem. I am searching something similar of this. Please post if u did.
theme in multistep form
I went for a non elegant solution. But it works. Simply defined a global variable in the form function which I was able to access from the theming function as well.
Karthik