0

I have created some fields on my user registration page named like - First Name (machine name - field_first_name), Last name (machine name - field_last_name) etc..

I want to change their #weight according to me to appear at the place where I like them to be from the form_alter function at my custom module..

For the default name & email I used -

$form['account']['name']['#weight'] = 7;
$form['account']['field_first_name']['#weight'] = 8;

& it worked..

But If I am using for added fields in this way like -

$form['account']['field_first_name']['#weight'] = 6;

It's not working...

Can I get any help in this ?

  • it depends on where you are keeping the fields. if it is with in a fields set then the weight will only be effected with in the fields set and not out side of it. – Mohammed Shameem Feb 2 '13 at 7:54
  • These are not inside the fieldset – RajeevK Feb 2 '13 at 8:08
  • account as a whole is in a group which contains the name password etc. the one we add might be out side of that... – Mohammed Shameem Feb 2 '13 at 8:19
  • @MohammedShameem - You were right. It's just independent and I could set the #weight by $form['field_first_name']['#weight'] = 6; , please give answer...I will accept... – RajeevK Feb 2 '13 at 11:12
1

Account as a whole is in a group which contains the name password etc. The one we add might be out side of that. That is why it is not effecting the weight.

0

Or you can copy the field in another "container field" and change the weight , something like this:

   $form['profile_one']['account'] = $form['account'];
   $form['profile_one']['account']['#weight'] = 200;

   // Hide login form from this render.
   $form['account']['#type'] = 'hidden';

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.