I have a user/register page for an installation that has profiles enabled. The default behavior displays the "extra" profile fieldset first, and the "Account information" fieldset second. How can I flip the order in which the fieldsets are displayed? I suspect part of my problem is that I don't fully understand how the fieldsets are represented within the form API.

Thanks in advance for any suggestions or pointers.

Clark Kee

Comments

ckee’s picture

Loading the Devel and Form Inspect modules provided some insight. It looks like I could alter the fieldset display order by adding/manipulating a #weight parameter to the 'account' fieldset.

C.

ckee’s picture

Found this discussion in the Module development forum: http://drupal.org/node/111925
with a couple pithy but correct suggestions: use the #weight parameter, and "write your own module and use hook_form_alter."

See also hiveminds hook_form_alter tutorial page.

With that info, and the form structure as revealed by Heine's Form Inspect module, I created a bare-bones module with only the functionality to allow it to be enabled, and a hook_form_alter for the form user_register.

function user_register_alter_form_alter($form_id, &$form) {
  if ($form_id == 'user_register') {
    $form['account']['#weight'] = -5;
  }
}

The verbose but self-documenting module name is user_register_alter -- hence the redundant-sounding function name.

What is implicit in the links cited above, and is no doubt obvious to drupal cognoscenti, but was not to me: with this technique it is only necessary to enable the module with the hook_form_alter for the alteration to take effect.

C.