From c21db64ae8f965f28342b6cf528d180a057c6412 Mon Sep 17 00:00:00 2001
From: Neil Drumm <drumm@3064.no-reply.drupal.org>
Date: Tue, 4 Jul 2006 08:52:55 +0000
Subject: [PATCH] #69403 by webchick, adoid overriding #theme set by
 hook_form_alter().

---
 includes/form.inc | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/includes/form.inc b/includes/form.inc
index 55910c175eaa..cd2e5b9eb067 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -145,11 +145,14 @@ function drupal_get_form($form_id, &$form, $callback = NULL) {
     }
   }
 
-  if (theme_get_function($form_id)) {
-    $form['#theme'] = $form_id;
-  }
-  elseif (theme_get_function($callback)) {
-    $form['#theme'] = $callback;
+  // Don't override #theme if someone already set it.
+  if (!isset($form['#theme'])) {
+    if (theme_get_function($form_id)) {
+      $form['#theme'] = $form_id;
+    }
+    elseif (theme_get_function($callback)) {
+      $form['#theme'] = $callback;
+    }
   }
 
   if (isset($form['#pre_render'])) {
-- 
GitLab