Does a controller exist to integrate inline entity form with profile 2? Thanks. Kevin

Comments

bojanz’s picture

Title: Profile2 controller » Inline Entity Form integration for Profile 2
Project: Inline Entity Form » Profile 2
Category: support » feature

Just like with Views, contrib modules are responsible for their own integrations. So let's ask the Profile 2 contributors.

zmove’s picture

+1 for this, it would be great to be able to create nodes on user registration using inline entity form. Unfortunatly, if IEF works with the core user registration system, it doesn't work with profile2 registration form.

pcambra’s picture

Issue summary: View changes

Bumped into this today and leaving my findings here.

IEF and Profile 2 seems to work "almost" out of the box except from one tiny bit.

When Profile 2 adds the submit handler in profile2_attach_form():

  $form['#submit'][] = 'profile2_form_submit_handler';

Inline entity form seems to completely ignore that in inline_entity_form_form_alter(), I'm pretty sure it's a module weight problem.

I didn't want to mess with the original weight of the modules so in my integration module (which has a higher weight than profile 2) I just did:

  if (isset($form['actions']['submit']['#submit'])) {
    $form['actions']['submit']['#submit'][] = 'profile2_form_submit_handler';
  }

And these 2 play nice together now.

Spleshka’s picture

Status: Active » Needs work

Okey, then we definately need to write some patches here :)

rohittiwarirvt’s picture

Suppose I want to refer company details content type on profile2 type called recruiters.
In order to integrate company details in recruiters registration page used inline entity form module and used inline_entity creation single value widget in entity reference field which would help to create company profile for the current recruiter on inline basis. Facing problem while saving the profile recruiter, wherein the after filling up the inline company form and submitting the form, only the profile2 fields are getting saved, but the company profile remains unchanged. From the above pointer i tried configuring module weight problem, in this case i suppose the profile2 form submit handler may be getting called prematurely before the inline entity form. Tried changing the weight of module from database
case |module | weight |test result
1 profile 0 failed
ief 0
2 profile 1 failed
ief 0
3 profile 0 failed
ief 1

After inspecting the $form and $form state variables, I get to know that for nodes in entity reference the inline entity form values gets attached

suppose I tried on article added a node reference field called company details and tried user inline entity form single values for creating the referenced entity, after inspection to the $form_state element for the Article content , we have $form_state['inline_entity_form'] value and after which the inline entity from attaches its trigger inline_entity_form_trigger_submit by using the inline_entity_form_form_alter . but this does not happens for profile . Please help.

chrislabeard’s picture

Any update on this issue? I have an IEF on a profile2 type. And it will not save on the profile2 page.

jazzper’s picture

Just want to say that comment #3 from pcambra works for me (thanks for posting this) and that people who don't know how to implement the code in a custom module can use Modules weight module. Install module and go to admin/config/system/modules-weight and set the weight of "Profile2" to -1.

paulmartin84’s picture

I don't think this fix works anymore. Profile2 now uses hook_module_implements_alter hook to change the weight of hook_form_alter.

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 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

paulmartin84’s picture

I have created a separate issue here https://www.drupal.org/node/2449913 as the title of this one maybe misleading, it seem it maybe orignally be referring to using inline entity form to reference profile2 entities rather than being used on a profile2 entity

kopeboy’s picture

I want to actually create a Profile2 entity in IEF while creating/editing a node.
Is it possible in general to have a profile without a user?

My errors (using dev versions):
When trying to add an Entity Reference field (even on a Content Type), using Inline Entity Form (multiple or single value), with Target type: Profile, I get this:

  • Warning: array_flip(): Can only flip STRING and INTEGER values! in EntityCacheControllerHelper::entityCacheLoad() (line 69 of /srv/bindings/bde2e1dc85df4b15b052058e9e181d97/code/sites/all/modules/entitycache/entitycache.module).
  • Notice: Trying to get property of non-object in profile2_access() (line 698 of /srv/bindings/bde2e1dc85df4b15b052058e9e181d97/code/sites/all/modules/profile2/profile2.module).
  • Warning: array_keys() expects parameter 1 to be array, null given in profile2_access() (line 698 of /srv/bindings/bde2e1dc85df4b15b052058e9e181d97/code/sites/all/modules/profile2/profile2.module).
  • Warning: array_intersect(): Argument #2 is not an array in profile2_access() (line 699 of /srv/bindings/bde2e1dc85df4b15b052058e9e181d97/code/sites/all/modules/profile2/profile2.module).

The list is even longer when I try to actually create the node, and the ER IEF field/form doesn't show up at all.
If I go back and set the widget as Autocomplete I get no errors and it works, but of course I cannot use that to create the entity inside the parent form.

P2790’s picture

Any updates, really need a fix for this

Road Kill’s picture

Its i unfortunate that is has not been committed yet but thank you Fruit Fly your solution worked very well.

imclean’s picture

rcodina’s picture

Thanks @imclean. The patch on the issue 2449913 worked for me!