I faced with problem when profile2 and account_profile modules are both enabled. account_profile module provide "Show this profile as part of user account form." option and if I have two ore more profile types with this option enabled then only last (by weight) profile appears on user/%id/edit page. It think it because in function profile2_attach_form(&$form, &$form_state) after field_attach_form('profile2', $profile, $form['profile_' . $profile->type], $form_state); we have duplicates in #pre_render array.

I suggest simple resolution - remove duplicates from that array.

Comments

Loparev created an issue. See original summary.

loparev’s picture

Title: Duplicates in $form['profile_' . $profile->type]['#pre_render'] array » Duplicates in #pre_render array
loparev’s picture

spleshka’s picture

loparev’s picture

Yes, I have seen that issue. It fixes problem on /user/register page. When I have updated profile2 to latest dev version problem on this page disappeared.

But I have another problem on /user/%id/edit page with account_profile module that uses profile2_attach_form. On user edit form there is only one profile appears.

Please, try to install profile2 (latest dev) and account_profile (latest dev). Create two profiles (test_1 with weight 0 and test_2 with weight 1) and add fieldset with some fields to each of them. Also check "show profile form on user registration page" and "Show profile as part of user account form" on settings page of profiles. Then check /user/register page - there is all right, all fieldsets with fields from test_1 and test_2 profiles are visible. Then check /user/%id/edit page and you will see that only test_2 profile's fields are visible on the page.

spleshka’s picture

Project: Profile 2 » Account Profile
Version: 7.x-1.x-dev » 7.x-2.0
Assigned: loparev » Unassigned
StatusFileSize
new499 bytes

Thanks for steps to reproduce the issue, @Loparev. I was able to get the described behavior. After my small research turns our that the issue is not in profile2, but in account_profile module: it calls profile2_attach_form() multiple times which cases the issue.

Changing the issue related contrib & attaching the patch.

danchadwick’s picture

Source of the issue is the related issue.

It would be slightly better to move the test to the outer if.