I'm having some issues using a theme_form_id function to theme my form in Drupal 6.

Namely, the theme function isn't being called.

I have a form defined with websupport_config_form. According to the API, all I should have to do to theme it would be to create a function called theme_websupport_config_form($form) and it will be automagically called. The problem is, the theme_ function isn't being called.

I can force it to be called if I define $form['#theme'] = theme_websupport_config_form($form); but the form array isn't being passed along. I've also tried passing in $form_state, but I'm still not getting any values from the theme function.

I'm trying to use element_children, and I keep getting a blank array. So to check, I called print_r() on $form and $form_state within the theme_ function, but they're not printing anything. Really getting frustrated here, and would really appreciate some help.

Ultimately I'm attempting to create a sortable table of values with checkboxes for administering some information pulled form a database, and it's not working. I've been banging my head against this for days now.

Comments

skywalker2208’s picture

Trying clearing your cache because I had the same issue where my theme function was not being called and I cleared my cache and it worked.

States to clear cache here

Predated’s picture

I clear the cache pretty religiously when doing any kind of development work. If I make a change to a file I'll clear the cache before refreshing the page to see how it looks, so I don't think that's the issue.

According to theme registry for special cases, the form theme has to be registered with hook_theme... I'm looking into that now, though it doesn't seem right that I would need to modify template.php to get this form themed...

Predated’s picture

After I implemented hook_theme() in my .module file, I got it working.

I'm still perplexed why the Form API states to theme a form, create another function named theme_form_id when it clearly doesn't work...

emartin24’s picture

I had spent a considerable amount of time trying to figure this out as well. It does not appear to mention anywhere in the API that you need to implement the hook_theme() to get this working.

But I did and now it is ;)

mtsanford’s picture

highly recommend checking out the new Pro Drupal Development 2nd edition by John VanDyk. It's not perfect, but gives a strong foundation that may be hard to come by otherwise, and may save a few headaches. Does a good job explaining hook_theme(), which did not exist in D5.

You say: "I'm still perplexed why the Form API states to theme a form, create another function named theme_form_id when it clearly doesn't work..."

Curios... where you are referring to?

emartin24’s picture

You say: "I'm still perplexed why the Form API states to theme a form, create another function named theme_form_id when it clearly doesn't work..."

Curios... where you are referring to?

The page is the quickstart guide: http://api.drupal.org/api/file/developer/topics/forms_api.html

Item #2 under Theming Forms.