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' => array(
'arguments' => array('form' => NULL),
'template' => 'page-node-form',
'render_element' => '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:
<div class='title'>
<?php print drupal_render($form['title']);?>
</div>
<div id='custom-form'>
<?php print drupal_render_children($form); ?>
</div>
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:
<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">
<div>
<div class="title" data-thmr="thmr_32"></div>
<div id="custom-form" data-thmr="thmr_32"></div>
</div>
</form>
As you can see, no form fields!