Theming Node Edit Forms I'm having an issue with theming our node edit forms. We are converting a Drupal 6 theme to Drupal 7 and its causing a lot of problems.

In our template.php we have

function dupublic_theme($existing, $type, $theme, $path) {
    return array(
            'page_node_form' =&gt; array(
                    'arguments' =&gt; array('form' =&gt; NULL),
                    'template' =&gt; 'page-node-form',
                    'render_element' =&gt; 'form',
            ),
    );
}


This successfully points Drupal at 'page-node-form.tpl.php'

Our goal is to pull out some fields into labeled areas to make our editor's job easier. We had a more complex layout, but I've simplified it for the following example.
In page-node-form.tpl.php I have the following:

&lt;div class='title'&gt;
    &lt;?php print drupal_render($form['title']);?&gt;
&lt;/div&gt;
&lt;div id='custom-form'&gt;
    &lt;?php print drupal_render_children($form); ?&gt;
&lt;/div&gt;


This, however, does not work. $form does not appear to exist, and dpm($form); displays as an empty array. We do not get any form fields at all - unless I remove everything from the tpl file, then I get some sort of default form display, which doesn't make sense. If the tpl file is empty no form should be displayed, but everything I am reading states that drupal_render($form['field']) and drupal_render_children($form) should work! They aren't!

This is what is rendered on page load:

&lt;form class="node-form node-page-form" action="/node/5/edit" method="post" id="page-node-form" accept-charset="UTF-8" data-thmr="thmr_33"&gt;
    &lt;div&gt;
        &lt;div class="title" data-thmr="thmr_32"&gt;&lt;/div&gt;
        &lt;div id="custom-form" data-thmr="thmr_32"&gt;&lt;/div&gt;
    &lt;/div&gt;
&lt;/form&gt;


As you can see, no form fields!
In your template.php the hook_theme implementation should look like that:

function dupublic_theme($existing, $type, $theme, $path) {
  return array(
    'page_node_form' =&gt; array(
      'template' =&gt; 'page-node-form',
      'render element' =&gt; 'form',
    ),
  );
}


Notice that in the return array 'render element' key is without underscore, and there is no 'arguments' key in Drupal 7 version of hook_theme(). It is replaced by 'variables' key, but the documentation states that:


  Each information array must contain either a 'variables' element or a
  'render element' element, but not both. Use 'render element' if you
  are theming a single element or element tree composed of elements,
  such as a form array, a page array, or a single checkbox element.


Another point that I notice is, that you used in your page-node-form.tpl.php file statements like:

&lt;?php print drupal_render($form['title']);?&gt;


I prefer to print the elements like that, and recommend you to do so:

&lt;?php print render($form['title']);?&gt;


It's a new function in Drupal 7 and it calls drupal_render() but first checks if the passed element is an array and also calls show() function if the element is set hidden.