If you have a profile type that has an entity reference field(referencing any entity type) that uses Inline Entity Form, When you try to create a new entity with the form and press save it fails to add and gives no error.

Below might be the cause that I have identified:
The profiles don't get attached to the user_profile_form until after "inline_entity_form_form_alter" has fired. This means the "profile2_form_submit_handler()" and "#ief_submit_all" flag never gets set. If you create your own hook menu to load the profile2 form directly using entity_ui_get_form. It works correctly.

The comment in Profile 2 says:
Ensure that execution of "profile2_form_user_register_form_alter()" is happens after all other implementations of "hook_form_FORM_ID_alter()"

However this has the side effect of also affecting "profile2_form_user_profile_form_alter" so the profiles are getting attached too late.

I believe this should be fixed here in Profile2

Comments

antonyanimator’s picture

Any solutions to a way around this / fix?

nimoatwoodwaysec’s picture

Also need a solution. Any ideas?

antonyanimator’s picture

Its started working for me, not too sure why. I'll investigate and report back

paulmartin84’s picture

I fixed this by adding this to a custom module, However this may have other undesired results, altering module weights could probably achieve similar results. Ideally this would be fixed in Profile2 rather than changing IEF's form_alter to fire later.

function MYMODULE_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'form_alter' && isset($implementations['inline_entity_form'])) {
    $group = $implementations['inline_entity_form'];
    unset($implementations['inline_entity_form']);
    $implementations['inline_entity_form'] = $group;
  }
}
antonyanimator’s picture

Hi, any updates on this? Changing module weights doesn't work

antonyanimator’s picture

@paulmartin84

Creating a custom module using your code works well for me. What do you think the undesired results may be?

welly’s picture

The function in #4 seems to be working well for me also. No undesired results as of yet.

spleshka’s picture

Status: Active » Needs review

Changing the issue status, will review the suggested patch when I find some time.

imclean’s picture

This adds the code in #4 to Profile2. Even though it works, I'm also not sure if it's the best way to go.

imclean’s picture

StatusFileSize
new583 bytes

The patch didn't attach for some reason.

rcodina’s picture

Patch on #10 works for me so +1 to RTBTC

@imclean Thank you so much!

rminkov’s picture

It works for me too. Thanks.

mkrizaj’s picture

Patch #10 works for me as well!

rcodina’s picture

Status: Needs review » Reviewed & tested by the community

Three good reviews means RTBTC

kingandy’s picture

Patch works for me.

  • Rick J committed 3d0a733 on 7.x-1.x authored by imclean
    Issue #2449913 by imclean, paulmartin84: Using inline entity form widget...
rickj’s picture

Status: Reviewed & tested by the community » Fixed
rickj’s picture

I committed this patch to dev (7.x-1.4-dev+3) as it was RTBC, but it seems it was only necessary to correct a side effect of another patch (issue #1097684).

The hook function added by that patch has caused various other side effects as well, so I am proposing taking the function out. Please see this comment, and if possible test the latest dev release with the patch in that comment applied.

Thanks

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

rcodina’s picture

I have updated Profile2 v1.3 (using patch on #10) to the new v1.6 and the error is back. I have opened a new issue: #3082062: Using inline entity form widget on a Profile2 field fails to work