How to produce the bug:
Register a template for a *_node_form in the theme hook_theme()
e.g.

mytheme_theme() {
    return array(
    'poll_node_form' => array(
      'template'  => 'poll-node-form',
      'arguments' => array('form' => NULL),
    ),
  );
}

Expected behaviour:
Theme system should recognize this newly registered form theming.

What happens instead:
drupal_render_form sees that node_form has specified #theme - and doesn't bother to check if any module or theme has registered its own theme for that form.

from drupal_render_form

// Don't override #theme if someone already set it.

Solution:
Remove the #theme item from the node_form form.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andremolnar’s picture

Title: function node_form should not specify #theme » theme system cannot override *_node_form forms

just changing title to better describe the actual bug

dvessel’s picture

Status: Needs review » Needs work

We chatted about this in IRC and there are other problems with removing '#theme'. Like the inability to override the default node_form.

andremolnar’s picture

FileSize
518 bytes

As per IRC conversation:
merlinofchaos points out that passing an array in #theme makes more sense - and solves the problem dvessel points out

$form['#theme'] = array($node->type .'_node_form', 'node_form');
andremolnar’s picture

Status: Needs work » Needs review

status change

chx’s picture

Status: Needs review » Reviewed & tested by the community

Very nice little patch, demonstrates the power of Drupal 6 and solves a regression.

dvessel’s picture

Yeah, works as expected.

A followup patch to register them would help too. But it may start looking dirty inside node_theme().

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

OK, committed, thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.