Hi,

I have used customization in user registration page

my code in template.php is

function CUSTOMTHEME _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
),

);
}

and in user-register.tpl.php is

      print drupal_render($form['name']); // prints the username field
    
      print drupal_render($form['mail']); // print the password field
    
        print drupal_render($form['submit']); // print the submit button
      

But the forms are displaying ( username + email + submit ) in q=user/register url

but while new user register submit button hits the values are not stored in database any solution plz help me to solve this issue

Comments

aharown07’s picture

Category: feature » support

Wish I could help with this. Trying to customize my own registration form and it looks like you're ahead of me. Just changing the category here because this doesn't look like a feature request.

sankar_jeya’s picture

if any idea plz giv tips

sankar_jeya’s picture

Component: user system » other

Hi,

I have used customization in user registration page

my code in template.php is

function CUSTOMTHEME _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
),

);
}

and in user-register.tpl.php is

      print drupal_render($form['name']); // prints the username field
   
      print drupal_render($form['mail']); // print the password field
   
        print drupal_render($form['submit']); // print the submit button
     

But the forms are displaying ( username + email + submit ) in q=user/register url

but while new user register submit button hits the values are not stored in database any solution plz help me to solve this issue

dawehner’s picture

Priority: Critical » Normal

you have to render also this:

<?php
print drupal_render($form['form_token']);
print drupal_render($form['form_id']);
?>
sankar_jeya’s picture

thanks dereine this works right

dawehner’s picture

Status: Active » Fixed

so this is fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

heine’s picture

The advice on #5 is not entirely correct.

You need to render the _rest_ of the form, not just a few specific fields with drupal_render($form). If you don't do this, you rely on FAPI implementation details. (Internal) fields may be added.

drupal_render_form allows this because it only renders elements once; calling it on $form won't get you elements that were already rendered.

sankar_jeya’s picture

sorry for this mistake if any plz note

hoamer’s picture

Version: 6.10 » 7.12
Status: Closed (fixed) » Active

Hi there,

I wanted to fill a field (city) after quering the value from a database.
It's hard to get it to work with the computed module, so i decided to solve it with a custom registration-form.

My user-register.tpl.php looks like this:


<?php print drupal_render($form['account']['name']); // prints the username field ?>
<?php print drupal_render($form['account']['mail']); // prints the mail field ?>
<?php print drupal_render($form['account']['pass']); // prints the password fields ?>

<?php print drupal_render($form['field_birthdate']); // prints the (birth)date picker ?>
<?php print drupal_render($form['terms_of_use']); // prints the terms of use-field ?>

<?php print drupal_render($form['locations']['0']['postal_code']); // location-field: postal code ?>



<?php print drupal_render($form['actions']['submit']); // print the submit button ?>

When I submit the form there is no response from it. No storing of the values.

So I added

print drupal_render($form['form_token']);
print drupal_render($form['form_id']);

as dereine in #4 said.

After adding it, i got an error, but can't explain why.
A not allowed selection was discovered.

I would be pleased, if someone can give me an explanation of what I am doing wrong and how to make it work.

Thanks ;)

Greetings
Hoamer

pasqualle’s picture

Status: Active » Closed (fixed)

in D7 use print drupal_render_children($form);

@hoamer: your problem is with the location field, that you did not render all of its elements.