This function only performs entity_form_field_validate('user', $form, $form_state);, which will validate the user account bundle, which is not there when $category != 'account'.
function user_profile_form($form, &$form_state, $account, $category = 'account') {
...
$form['#user_category'] = $category;
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);
}
This can lead to errors during validation as these fields are still validated. See #1200890: Fields that trigger errors using hook_field_validate() trigger PHP errors
Comments
Comment #1
alan d. commentedComment #2
alan d. commentedIt would make sense to extend this to the submit handler as well... This really needs review by the field maintainers!
Comment #4
alan d. commentedI think that this strongly suggests that removing validation could also be a bad idea.
Moving into the field system, a safe check could be the existence of the instance in the results from field_form_get_state(), again requiring feedback from others.
Comment #5
alan d. commentedComment #6
alan d. commentedMajor in regards to the Name Field module, but not in the grander scheme :)
It would be great to have someone to review the last patch, all it does is to check that there was a valid form element returned from field_form_get_state() during field widget validation. [One singular isset() check]. This is a complete show stopper for using this field in Profile2, and may it effect other multi-component fields too.
Comment #7
alan d. commentedSome quick tests seem to show that this was strangely resolved somewhere else in Drupal 7.4 albeit I can not see where!