Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Does a controller exist to integrate inline entity form with profile 2? Thanks. Kevin
Comments
Comment #1
bojanz CreditAttribution: bojanz commentedJust like with Views, contrib modules are responsible for their own integrations. So let's ask the Profile 2 contributors.
Comment #2
zmove CreditAttribution: zmove commented+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.
Comment #3
pcambraBumped 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():
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:
And these 2 play nice together now.
Comment #4
SpleshkaOkey, then we definately need to write some patches here :)
Comment #5
rohittiwarirvt CreditAttribution: rohittiwarirvt commentedSuppose 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.
Comment #6
chrislabeard CreditAttribution: chrislabeard commentedAny update on this issue? I have an IEF on a profile2 type. And it will not save on the profile2 page.
Comment #7
jazzper CreditAttribution: jazzper commentedJust 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.
Comment #8
paulmartin84 CreditAttribution: paulmartin84 commentedI 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
Comment #9
paulmartin84 CreditAttribution: paulmartin84 commentedI 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
Comment #10
kopeboy CreditAttribution: kopeboy commentedI 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.
Comment #11
P2790 CreditAttribution: P2790 commentedAny updates, really need a fix for this
Comment #12
Road Kill CreditAttribution: Road Kill commentedIts i unfortunate that is has not been committed yet but thank you Fruit Fly your solution worked very well.
Comment #13
imclean CreditAttribution: imclean commentedSee also #2449913: Using inline entity form widget on a Profile2 field fails to work
Comment #14
rcodina CreditAttribution: rcodina commentedThanks @imclean. The patch on the issue 2449913 worked for me!