I have a profile2 regpath displaying my profile2 form, and the system default account registration form below it. I need to move the account email field up into the container with the profile2 fields.
I have altered the form and moved the account mail field from the account form, into the profile form, and I have created an additional validation handler to try insert the mail value into the $form_state value so the user_account_form_validate() doesn't choke on a missing ['mail'] index:
function si_student_form_user_register_form_alter(&$form, &$form_state, $form_id) { global $user; // remove fieldgroups and tabs for anonymous users, e.g. /student/register if($user->uid == 0) { // move email field from account to below profile2 name fields $email = $form['account']['mail']; unset($form['account']['mail']); // add email to profile $form['profile_student']['mail'] = $email; // change weights $form['profile_student']['mail']['#weight'] = 3; // custom validation handler to inject mail value into // correct place in $form_state['values'] array $form['#validate'][] = '_si_student_register_anonymous_validate'; //dpm($form); }}function _si_student_register_anonymous_validate($form, &$form_state) { $form_state['values']['mail'] = $form_state['values']['profile_student']['mail'];}
However this isn't working, and I get the following:
Any ideas? I'm not sure I'm taking the right approach here. Thanks