Theming the User Registration Form in Drupal 6 | Trellon - 0 views
www.trellon.com/...theming-user-register-form-d6
drupal forms drupal_forms drupal_theme user_register template override
![](/images/link.gif)
-
<?phpfunction themename_theme($existing, $type, $theme, $path) { return array( ... // tell Drupal what template to use for the user register form 'user_register' => array( 'arguments' => array('form' => NULL), 'template' => 'user-register', // this is the name of the template ), ... );}?>
-
<div id="registration_form"> <div class="field"> <?php print drupal_render($form['account']['name']); // prints the username field ?> </div> <div class="field"> <?php print drupal_render($form['account']['pass']); // print the password field ?> </div> <div class="field"> <?php print drupal_render($form['submit']); // print the submit button ?> </div> </div></div>
- ...3 more annotations...
-
Don't forget to render hidden fields or it won't work ;) echo drupal_render($form['timezone']); echo drupal_render($form['form_build_id']); echo drupal_render($form['form_id']);
-
you also have to print the "token" in order to make the form work print drupal_render($form['form_token']);
-
From my own experience using a form tpl.php, you need to print the whole $form at the very end of the template to ensure that the form will validate upon submission. <?php print drupal_render($form); ?> Just adding the hidden form_build_id and the form_id fields will not mean the form will work. Printing the entire form at the end, however, will mean that all the stuff you wanted to hide in making the template will show. For those fields, include "unset" statements for each one: <?php unset($form['field_to_hide']); ?> Please correct me if I'm wrong or if there is a better way to do this.