Thanks for a really great module!

Do you have any suggestions for how to adjust the ordering of fields on the registration page when some fields are created by core like the username and email address fields?

Best, Paul

Comments

grasmash’s picture

You should be able to control the weight of the P2RP fieldset via the UI, as well as the weights the core fields.

You can find a discussion here: #1674970: reg form output order when using additional non-profile2 profile fields.

For the best control, I would suggest using FAPI to change element weights. If that does not work, please describe your issue in more detail.

Anonymous’s picture

Thanks for the reply :)

I can use the UI or the FAPI to arrange core fields and profile2 fields separately but I can't rearrange them all together i.e.

#Registration form

First Name [profile2]
Second Name [profile2]
Username [Core]
Email Address [Core]

.. other profile 2fields

Best, Paul

BazzeFTW’s picture

I'm having the same issue.

grasmash’s picture

As long as you don't wrap P2RP fields in a fieldset, the core field weights and profile2 field weights should respect eachother. Are the fields in a fieldset? Can you check the markup?

stutibhavsar’s picture

I am also facing the same problem. The profile 2 fields are wrapped in a fieldset. I can change the core fields weight but not the profile 2 fields.
Please advice on the same.

grasmash’s picture

Ok, it seems like this request is getting some critical mass. I'll look into the issue this weekend.

hawkeye217’s picture

Having the same issue on a fresh install of D7 and profile2-2.x-dev. I created a P2 field called "name" with a weight of -100 and the core registration username/password fields set at their default of -10. No fieldsets. The registration form still displays the core fields before the p2 field. Unless that's by design...

I haven't tried using form_alter's #weight yet...

Anonymous’s picture

Did you have a look into this? This is something that I now need to try and fix.

Best, Paul

Anonymous’s picture

Work around I found for a project ..

function ourgamefootball_form_profile2_form_alter(&$form, &$form_state){
  
    $form['account']['field_profile_first_name'] = $form['profile_account_profile']['field_profile_first_name'];  
    $form['account']['field_profile_first_name'] = $form['profile_account_profile']['field_profile_last_name'];

    unset($form['profile_account_profile']['field_profile_first_name']);
    unset($form['profile_account_profile']['field_profile_last_name']);  

   $form['#submit'][] = 'ourgamefootball_form_profile2_form_submit';
}

function ourgamefootball_form_profile2_form_submit($form, &$form_state) { 

  if (is_array($form_state['values']['profile_account_profile']) {
 
    $form_state['values']['profile_account_profile']['field_profile_first_name']  = array();
    $form_state['values']['profile_account_profile']['field_profile_first_name']['und'] = $form_state['values']['field_profile_first_name'][0]['und'];  
  
    $form_state['values']['profile_account_profile']['field_profile_last_name']  =  array();
    $form_state['values']['profile_account_profile']['field_profile_last_name']['und'] = $form_state['values']['field_profile_first_name'][1]['und'];
  }
  	
}
mortona2k’s picture

Thanks Paul,

I'm a little surprised that this works:

$form['#submit'][] = 'ourgamefootball_form_profile2_form_submit';

Since it's operating after all the other form validation and submission handlers. But it seems to work, so thanks a ton for documenting it!

ssoulless’s picture

Priority: Normal » Minor
Status: Active » Reviewed & tested by the community

tested, #9 works

ssoulless’s picture

Issue summary: View changes

Forgot to mention that this refers to the registration page

DrCord’s picture

Issue summary: View changes

The fix in #9 worked for me. I needed to move a profile 2 field from one profile section to another for a client on only the registration page...nothing else seemed to work, but this did! Thanks @paulbooker

grasmash’s picture

Status: Reviewed & tested by the community » Active

This issue has no patched, and so should not be marked as "reviewed and tested by community".