0

I'm using Drupal 7 and I've created a user-register-form.tpl.php to override the default user registration page at user/register. It displays all the fields I need except for the password fields. I'm using LoginToboggan to allow users to set a password when registering, so in the default user registration page 2 password fields are displayed.

I have the following in my template.php file:

function scholarly_lite_theme() {
$items = array();

$items['user_register_form'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'scholarly_lite'),
'template' => 'user-register-form',
'preprocess functions' => array(
'scholarly_lite_preprocess_user_register_form'
),
);
return $items;
}

function scholarly_lite_preprocess_user_register_form(&$vars) {
$args = func_get_args();
array_shift($args);
$form_state['build_info']['args'] = $args;
$vars['form'] = drupal_build_form('user_register_form', $form_state['build_info']['args']);
}

and my user-register-form.tpl.php

<?php
print render($form['form_build_id']);
print render($form['form_id']);

print render($form['account']['name']);
print render($form['account']['mail']);
print render($form['account']['pass-pass1']);
print render($form['account']['pass-pass2']);

print render($form['field_gender_account']);
print render($form['field_date_of_birth_account']);

print render($form['captcha']);

print drupal_render($form['actions']);
?>

It displays all except password fields. What am I doing wrong?

If I add:

print drupal_render_children($form);

Then it adds the password fields below the Register button which is not idea but then the form works.

Also, I am using the "Auto Assign Role" module with "User Choice" set to allow users to select a second role if relevant to them during registration. I can do without this. When adding render_children as mentioned above, it displays this option below the password fields.

Please can someone assist with how I can get the Password fields displayed without using render_children.

Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.