Forgive me if this sounds a little ranty, but I just spent an unreasonable amount of time trying to perform a simple task.

What I'm trying to do is theme the User Registration form. The problem is that there's no theme specified in the form function and there are no templates used to create the form. So, I did a search and got several hits on how to do this but all of them were geared toward versions 4 and 5. The threads usually ended with someone complaining that the posted solution doesn't work in version 6.

A little more research provided me with the $form['#theme'] attribute. I was able to use hook_form_alter easy enough, but the following code did nothing:

function mymodule_form_user_register_alter(&$form, $form_state) {
  $form['#theme'] = 'user_regsiter_form';
}

function theme_user_regsiter_form($form) {
  //theme output
}

Then I saw something that said that $form['#theme'] must be set in something called hook_pre_render. Unfortunately, I could find very little information on how to use hook_pre_render. What I did find didn't provide any real world examples of how to use it. I tried a few varations that I thought might work, but they didn't.

I also saw some documentation that made me think that hook_theme was the tool to use. Sadly, I couldn't make heads or tails out of how to use it either.

This should be a simple task. What am I missing here? Any help would be greatly appreciated.

MK

Comments

vm’s picture

apis are documented at api.drupal.org

I don't know what sites you are referring to, where it concerns snippets/tutorials that weren't working.

If you've not seen:
drupal.org/node/350634
11heavens.com/theming-the-register-form-in-Drupal-6
trellon.com/content/blog/theming-user-register-form-d6

Nick Lewis’s picture

Did you remember to register the theme function in hook_theme? E.g.

// implementation of hook_theme() 
function mymodule_theme() {
  return array(
   // keeping the misspelling. 
    'user_regsiter_form' => array('arguments' => array('form' => array())
  );
}

function theme_user_regsiter_form($form) {
  //theme output
}


Be sure to clear out your cache after you add hook_theme().

--
"I'm not concerned about all hell breaking loose, but that a PART of hell will break loose... it'll be much harder to detect." - George Carlin
--
Personal: http://www.nicklewis.org
Work: http://www.zivtech.com

mk31762’s picture

I probably never hit on the correct combination of search terms - I often have that problem.

These are very helpful posts - exactly the information I was looking for. Thank you!