Hi All,
I have been reading the forms api and the module developers guide in the the handbook section on the site and their is something I am having trouble with.
I am trying to modify ./modules/user/user.module to show the help text at the top of the screen instead of in the middle. To see what I mean check out my site at http://www.irwinresources.com/user/register
I realise that you are not meant to change core modules but I believe it is the only way to do what I want.
The drupal_get_form('user_register'); returns the following:
Array ( [user_registration_help] => Array ( [#value] =>
Hello and Welcome
By creating an account you will be able to do many cool things which may expand to more and more over time depending on how much of a control freak I want to be over my web site. It also allows me to know how many people are comming to the site and what your contact details are if I don't have them already.
NOTE: If you make your username your name then it will appear when you make posts and comments etc.
If your some weird guy or girl from some other country other then Australia that I don't know then I guess you can just put crap in for the mobile number but you will need a correct email address to recieve your login password.
)
[account] => Array ( [#type] => fieldset [#title] => Account information [name] => Array ( [#type] => textfield [#title] => Username [#default_value] => [#maxlength] => 60 [#description] => Your preferred username; punctuation is not allowed except for periods, hyphens, and underscores. [#required] => 1 ) [mail] => Array ( [#type] => textfield [#title] => E-mail address [#default_value] => [#maxlength] => 64 [#description] => A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail. [#required] => 1 ) ) [Personal Information] => Array ( [#type] => fieldset [#title] => Personal Information [#weight] => 0 [profile_FirstName] => Array ( [#type] => textfield [#title] => First Name [#default_value] => [#maxlength] => 255 [#description] => [#required] => 1 ) [profile_LastName] => Array ( [#type] => textfield [#title] => Last Name [#default_value] => [#maxlength] => 255 [#description] => [#required] => 1 ) [profile_Mobile] => Array ( [#type] => textfield [#title] => Mobile [#default_value] => [#maxlength] => 255 [#description] => A mobile is known as a cell phone in some Countries [#required] => 1 ) [profile_Birthday] => Array ( [#type] => textfield [#title] => Birthday [#default_value] => [#maxlength] => 255 [#description] => Please enter as YYYY-MM-DD [#required] => 1 ) [profile_WebSite] => Array ( [#type] => textfield [#title] => Web Site [#default_value] => [#maxlength] => 255 [#description] => Your web site e.g. your myspace or blog or what ever else. [#required] => 0 ) ) [submit] => Array ( [#type] => submit [#value] => Create new account [#weight] => 30 ) )
I would have thought that when the form gets build it would build it in order from the first array element to the last which would do what I want but for some reason the user_registration_help array element is being displayed in the middle and the Personal Information array element is being displayed at the top.
If i can get the Personal Information element to display at the bottom the everything should work the way I want but I am not sure how to do this.
Can someone please point me in the right direction?
Kind Regards,
Anthony Irwin
Comments
Check out the #weight
Check out the
#weightelement in the forms api.And you don't have to hack core to do this. Write your own module, and use hook_form_alter().
- Corey
Thanks for that I didn't see
Thanks for that I didn't see the weight option but I was looking through the tutorials mainly.
I didn't do the hook_form_alter() I will have to look into how to do that more.
I did a quick hack to get it going the way I want quickly I added the below line just before return $form; in the user_register() function of the user.module.
$form['user_registration_help']['#weight'] = '-10';
Thanks for your help and as I learn more about the module development I will fix it to use the hook_form_alter() you talked about so I am not changing the core modules.
Kind Regards,
Anthony Irwin
http://www.irwinresources.com