Forms API won't call theme functions if theme_ doesn't exist.

merlinofchaos - December 22, 2005 - 19:19
Project:Drupal
Component:forms system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

In the forms API, all forms are supposed to be themeable.

However, forms.inc checks to see if a theme_ function exists for a given formid; if it doesn't, it never calls a specific themed function.

The answer is to create a new theme function, which I called 'theme_get_function' which is mostly the code from theme(). It checks for a theme function and, if it finds it, returns it; otherwise it returns false.

theme() then just calls that and executes the function it returns, if one was found.

Patch attached.

AttachmentSizeStatusTest resultOperations
theme_get_function.patch1.61 KBIgnoredNoneNone

#1

chx - December 29, 2005 - 05:41

Rerolled.

AttachmentSizeStatusTest resultOperations
theme_get_function_0.patch1.93 KBIgnoredNoneNone

#2

chx - December 29, 2005 - 05:42
Status:needs review» reviewed & tested by the community

#3

merlinofchaos - December 29, 2005 - 05:51

New patch has better doxy, but should be same otherwise.

AttachmentSizeStatusTest resultOperations
theme_get_function2.patch2.57 KBIgnoredNoneNone

#4

merlinofchaos - December 29, 2005 - 05:53

Ugh cvs diff hates me

AttachmentSizeStatusTest resultOperations
theme_get_function2_0.patch2.39 KBIgnoredNoneNone

#5

Dries - January 6, 2006 - 07:39

Not sure I like this patch. Has this been benchmarked?

#6

merlinofchaos - January 10, 2006 - 19:22

After fiddling with xdebug:

The call added 15ms in 161 calls to theme() on my server (testing just the front page, which had 10 nodes on it, plus some blocks, etc). My server runs slow, too, and was taking 1200ms to run the entire page.

#7

Dries - January 10, 2006 - 19:36
Status:reviewed & tested by the community» fixed

Committed to HEAD. Thanks.

#8

raema - January 24, 2006 - 21:47
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.