[development] theming in D7

Earl Miles merlin at logrus.com
Sat Oct 23 15:14:17 UTC 2010


On 10/22/2010 1:56 PM, Bob Hutchinson wrote:
> In D7 I get somewhat different behaviour:
> 
> If I do not create an entry in the theme registry, all works as expected, but 
> if I do, things start to behave oddly.
> 
> function mymodule_theme() {
> ....
>     'mymodule_thingy_form' => array(
>       'variables' => array(
>         'form' => NULL,
>       ),
>     ),

In D7 the above should actually be:

     'mymodule_thingy_form' => array(
       'render element' => 'form',


> ....
> }
> and create a function
> function theme_mymodule_thingy_form($variables) {
>   $form = $variables['form'];
>   $output = drupal_render($form);
>   return $output;
> }

You should use either render() or drupal_render_children() rather than
drupal_render(). So far as I could figure out, drupal_render() should no
longer be used inside theme functions. You use render() to render a
specific element, and drupal_render_children() to render all the
children but NOT the element (which is what you want when attempting to
render $form since that is currently being rendered).



More information about the development mailing list