The name field module uses hook_field_validate() and it throws the following errors on save.

Notice: Undefined index: array_parents in field_default_form_errors() (line 342 of C:\path\modules\field\field.form.inc).
Recoverable fatal error: Argument 2 passed to drupal_array_get_nested_value() must be an array, null given, called in C:\path\modules\field\field.form.inc on line 342 and defined in drupal_array_get_nested_value() (line 6331 of C:\path\includes\common.inc).

The strangest thing is that it appears to be caused by the user bundle field being validated when this shouldn't, i.e. it is on the user bundle, NOT the profile2 bundles.

Comments

alan d.’s picture

Sorry, fairly light on info.

Install profile2 + name field (drupal.org/projects/name)
Add a name field to the user bundle
Configure a profile category and add a text field or something safe.
Try editing this profile tab, and the error should show up on save

alan d.’s picture

OK, tracked down the bug (it is a core bug)

function user_profile_form($form, &$form_state, $account, $category = 'account') {
  ....
  if ($category == 'account') {
    user_account_form($form, $form_state);
    // Attach field widgets.
    field_attach_form('user', $account, $form, $form_state);
  }
  ....
  $form['#validate'][] = 'user_profile_form_validate';
  // Add the final user profile form submit handler.
  $form['#submit'][] = 'user_profile_form_submit';

  return $form;
}

/**
 * Validation function for the user account and profile editing form.
 */
function user_profile_form_validate($form, &$form_state) {
  entity_form_field_validate('user', $form, $form_state);
}

So the user bundle fields are validated no matter what.

I'm leaving this open for tracking and I've opened: #1200910: user_profile_form_validate() is always called, even when $category != 'account'

alan d.’s picture

Status: Active » Closed (fixed)

This appears to be resolved as of Drupal 7.4 (or I simply can not replicate the edge case that triggered it any more)