[development] [SOLVED] Question on #theme attribute in D6 FAPI

Syscrusher syscrusher at 4th.com
Tue Jul 15 22:30:13 UTC 2008


On Thu, 2008-07-10 at 05:32 -0400, Syscrusher wrote:
> On Thu, 2008-07-10 at 02:30 -0400, Darrel O'Pry wrote:
> > FAPI and the theme layer are not the same... A theme function must
> be
> > declared in hook_theme() in order for theme() to call it. FAPI
> simply
> > calls  theme() with the $element.
> 
> Ahhhhhh....that helps a LOT.

And indeed it did. I have the function call working perfectly now. For
the benefit of others new to D6 and facing the form-theming issue, my
code footprint looks like this:

In the form generation:

$form['my_module']['#theme'] = 'my_module_form';

Implementing hook_theme():

function my_module_theme() {
  return array(
    'my_module_form' => array(
      'arguments' => array('element' => NULL),
    ),
  );
}

Finally, the actual theme function signature:

function theme_my_module_form($form)

What I was missing was the hook_theme() registration and the fact that
the string passed as the #theme value does *not* begin with 'theme_',
rather, that is added by the core as it invokes the theme hook.

Thanks to all who replied.

Scott
-- 
Syscrusher <syscrusher at 4th.com>



More information about the development mailing list