Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By astanley86 on
Hello,
I get the following error message preventing the rendering of the user registration page:
Notice: Undefined index: render element in theme() (line 824 of /home/volunteermark/www/www/includes/theme.inc).
Warning: Missing argument 2 for user_register_form(), called in /home/volunteermark/www/www/sites/all/themes/volunteermark/template.php on line 164 and defined in user_register_form() (line 3643 of /home/volunteermark/www/www/modules/user/user.module).
Recoverable fatal error: Argument 1 passed to drupal_array_get_nested_value() must be an array, null given, called in /home/volunteermark/www/www/modules/field/field.form.inc on line 450 and defined in drupal_array_get_nested_value() (line 6339 of /home/volunteermark/www/www/includes/common.inc).
Here is what my user-register.tpl.php source code looks like:
<h1>Testing that this is my own user registration form</h1>
<?php print render($form['form_id']); ?>
<?php print render($form['form_build_id']); ?>
<?php
print render ($form['field_firstname']);
print render ($form['field_lastname']);
print render ($form['field_dob']);
print render ($form['name']);
print render ($form['mail']);
print render ($form['pass']);
print render ($form['timezone']);
print render ($form['form_token']);
print drupal_render($form['actions']); ?>
<input type="submit" name="op" id="edit-submit" value="Create" class="form-submit" />
What am I doing wrong? I have been able to successfully do this in Drupal 6 and can't find any documentation for what I would need to do for drupal 7. Thank you for your help!
Andrew
Comments
Drupal 7 uses '--' notation
Drupal - 7:
node--[content-type].tpl.php
Example: node--blog.tpl.php
Well I think it is correctly
Well I think it is correctly calling the user-register.tpl.php file because here is what I have in my template.php:
The user edit page works and the user login page works too. And if I remove the reference to the user register page then the error goes away and I get the standard drupal user registration page.
Instead of arguments you need
Instead of arguments you need the following
in your hook_theme
Lee Rowlands
Yes this works! Thank you
Yes this works! Thank you Larowlan.
Can you post an example of
Can you post an example of what you got working, I'm running into this same problem as well.
Here is
Here is example:
via http://drupal.org/update/modules/6/7#hook_theme_render_changes
'user_register' does not work for me in template.tpl.php.
This is my code in template.tpl.php:
'user_login' and 'user_pass' are work. I don't know why 'user_register' doesn't work.
I want to customize the registration form. Thanks for your help.
OK, I got it
I user 'user_register_form' instead of 'user_register'
I have the same problem
Hi,
I have the same error as the original post, ie:
Warning: Missing argument 2 for user_register_form(), called in C:\tools\Sites\mytestsite\sites\all\themes\daniel\template.php on line 248 and defined in user_register_form() (line 3682 of C:\tools\Sites\mytestsite\modules\user\user.module).
Recoverable fatal error: Argument 1 passed to drupal_array_get_nested_value() must be an array, null given, called in C:\tools\Sites\mytestsite\modules\field\field.form.inc on line 473 and defined in drupal_array_get_nested_value() (line 6364 of C:\tools\Sites\mytestsite\includes\common.inc).
My hook function and preprocess method are as below:
The error occurs in the preprocess method. If I remove that line of code, the page will render correctly. But I can then not access the form fields in my user-register-form.tpl.php:
Please let me know what I'm doing wrong.
Try this instead...
EDIT: I made a more comprehensive comment below -- this needs to be deleted but I can't figure out how.
excuse my ignorance, but how
excuse my ignorance, but how do I print 2 or more fields in the same line? for example:
print render ($content['field_lastname']) + print render $content['field_lastname']) in the same row. sorry for my bad English, Greetings from Argentina!
Adrian
You need to do this using CSS actually
Hey Adrian,
you could use these two methods
*for the fields you want to display in one line put- display: inline-block;
*for the fields you want to display in one line put- float:left;
and if some other field unnecessarily appears beside then for that field put clear: left;
I believe this should work. All the best. :)
Success
I used this thread as a base for my own successful theme modifications to User Registration and I thought I'd share in case someone comes along looking for the same things I did.
Firstly, in your theme's template.php:
-------------------------------------
Hopefully you guys can find this information useful about your user-register.tpl.php
Account fields
Account fields are rendered following the pattern of the two required fields, 'name' and 'mail':
Profile2 Support
To load Profile2 fields into the user registration form manually, use this pattern:
Also, I make use of field group module (here) with Profile2 and noticed that I didn't need to include anything about the field group a Profile2 field is in to render that field.
CAPTCHA
If you use the CAPTCHA module and need to build your own user-register.tpl.php you'll need this to render it:
This took me longer than it should of to figure it out.
Submission
Lastly, if you want your form to actually be usable, the following snippet is required to build the form action stuff:
Enjoy!
...
...
Thanks. I was wondering how
Thanks. I was wondering how to separate the fields of account field. This helped me
Regards,
Subhojit Paul
For the last part, you should
For the last part, you should use instead
print drupal_render_children($form);
Drupal will render all elements that have not been rendered yet, inluding
$form['form_build_id']
and$form['form_id']
.So if you or a module adds an element (visible or not), it will be automatically rendered.
Thanks, that's great
Thanks, that's great information. If I could update my post I would.
Form Fields not rendering
I followed all the code in this thread and I have gotten it so my user--register.tpl.php template is recognized, but none of my fields are showing up. I'm pretty new to this, so I'm not sure where I'm messing up.
Here is what's in my template.php:
And this is what's in my user--register.tpl.php:
<h1>Testing that this is my own user registration form</h1>
All that's showing up on the page is "Testing that this is my own user registration form"
Any guidance would be greatly appreciated!
Regarding profile2 form
Regarding profile2 form elements and in order for them to be available, you have to tick the checkbox Show during user account registration. under your profile type. Otherwise the $form['profile_name'] won't be available.
Whenever I post print drupal
Whenever I post
print drupal_render_children($form);
In the form it pulls all of my original form data, defeating the pourpose.What do i do to get the actions to complete without pulling the whole form?
thank you for your tutorial
thank you for your tutorial it was very helpful.
I was wondering what syntax should I use to output any verification error messages to the page. Any help is appreciated.
error class not adding to the form
i have done exactly the same thing above but on submit the form i won't get error class on the elements am i doing something wrong ? or missing out anything????//
From tutorial in this link :-
From tutorial in this link :- https://www.drupal.org/docs/7/theming/overriding-themable-output/customi...
We don't need to pass a variable containing the form content we want rendered in the preprocess function. The variable exists already in the $vars array and can be rendered in the .tpl.php file.
need help displaying password fields
This is an old thread but I'm having an issue with this and hoping someone is able to assist.
I've created a user-register-form.tpl.php to override the default user registration page. 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