hook_theme not being called in module I'm working on a module that has a custom output for the form that's being called, and this form has multiple pages. The multiple page part is being called correctly, but I can't get the theme to render the form.

I've got the following code:

&lt;?php

// Page callback to render the form
function mymodule_main() {
    return drupal_render(drupal_get_form('mymodule_form'));
}

// Picks which form to call
function mymodule_form($form, &amp;$form_state) {
    drupal_set_message('Picking form to use');
    if(!empty($form_state['page_num']) &amp;&amp; $form_state['page_num'] == 2) {
        drupal_set_message('Form 2');
        return mymodule_form_two($form, &amp;$form_state);
    } else {
        drupal_set_message('Form 1');
        return mymodule_form_one($form, &amp;$form_state);
    }
}

// Form definition for the first page
function mymodule_form_one($form, &amp;$form_state) {
    return array(
        // ...
        '#theme' =&gt; 'mymodule_theme_one',
    );
}

// Hook theme call
function mymodule_theme() {
    drupal_set_message('Hook Theme has been called');
    return array(
        'mymodule_theme_one' =&gt; array('render element' =&gt; 'form'),
    );
}

// My custom theme for the first page
function theme_mymodule_theme_one($vars) {
    drupal_set_message('Theme for first form has been called');
    // Code to style the form
    return $output;
}


In the theme_mymodule_theme_one function I move some of the form definition things around, unset some variables for output, etc. When I visit my page I defined in my hook_menu() call I get the form I defined in mymodule_form_one but without any of the work done in theme_mymodule_theme_one and I only get the following two messages:


Picking form to use
Form 1


I don't see any of the other messages. 

Edit

I've cleared the cache manually as well as disabled and re-enabled the module and the theme code still is not being called.
The only thing you should need to do is clear Drupal's cache; hook implementations are cached so once you've written the function you need to clear the cache to get the new data into the registry.

One other small thing, you probably shouldn't be returning an array like you currently are from your form builder function.

I'm pretty sure Drupal sets up the $form variable it passes into the function through drupal_get_form with some required details, so returning an array (and not the original $form element) will probably mean your return from the function is missing something. The usual way would be to do it like this:

function mymodule_form_one($form, &amp;$form_state) {
  $form['#theme'] = 'mymodule_theme_one';      

  return $form;
}