I have a custom module that overrides the /user/register page so that in addtion to username and email it also asks for about 10 or so Profile2 pieces of information.
The code I have so far:
$form['hi'] = array(
'#type' => 'fieldset',
'#prefix' => '<div id="container_a">',
'#suffix' => '</div>',
'#title' => t('Additional Info'),
);
$form['hi']['l'] = array(
'#type' => 'fieldset',
'#prefix' => '<div id="left">',
'#suffix' => '</div>',
);
$form['hi']['r'] = array(
'#prefix' => '<div id="right">',
'#suffix' => '</div>',
'#type' => 'fieldset',
);
$form['hi']['l']['h_ph'] = $form['profile_memberlist']['field_home_phone']['und'][0];
The form renders a space for username, email and Home Phone. I fill out the form, and submit, and I get the following:
Thank you for applying for an account. Your account is currently pending approval by the site administrator. In the meantime, a welcome message with further instructions has been sent to your e-mail >address.
Error message
Notice: Undefined index: profile_memberlist in profile2_form_submit_build_profile() (line 471 of /var/www/html/example/sites/all/modules/profile2/profile2.module).
Warning: array_merge(): Argument #1 is not an array in field_default_extract_form_values() (line 36 of /var/www/html/example/modules/field/field.default.inc).
Recoverable fatal error: Argument 2 passed to drupal_array_get_nested_value() must be an array, null given, called in /var/www/html/example/modules/field/field.default.inc on line 38 and defined in drupal_array_get_nested_value() (line 6608 of /var/www/html/example/includes/common.inc).
I've double checked and the memberlist is the name ( machine name) of the profile2 I am trying to get populated.