[development] theming in D7

Bob Hutchinson hutchlists at midwales.com
Sat Oct 23 17:36:58 UTC 2010


On Saturday 23 October 2010, Earl Miles wrote:
> 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).

OK, thanks, I will try this.

-- 
-----------------
Bob Hutchinson
Midwales dot com
-----------------


More information about the development mailing list