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:
<?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, &$form_state) {
drupal_set_message('Picking form to use');
if(!empty($form_state['page_num']) && $form_state['page_num'] == 2) {
drupal_set_message('Form 2');
return mymodule_form_two($form, &$form_state);
} else {
drupal_set_message('Form 1');
return mymodule_form_one($form, &$form_state);
}
}
// Form definition for the first page
function mymodule_form_one($form, &$form_state) {
return array(
// ...
'#theme' => 'mymodule_theme_one',
);
}
// Hook theme call
function mymodule_theme() {
drupal_set_message('Hook Theme has been called');
return array(
'mymodule_theme_one' => array('render element' => '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.
mymodule_theme()
is not invoked just because you don't see the "Hook Theme has been called" message on screen?theme('mymodule_theme_one', $params)
I don't get any output.