I'm using both the Field Collection module and the Inline Entity Form module.

If I have an entity reference using Inline Entity Form, and the referenced content type includes a Field Collection, the field collection fails to save and I am unable to create the whole node. If I click "Add another item" to add a second field collection item, I get an Ajax error:

Uncaught AjaxError: 
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /node/add/news?element_parents=field_testref/form/inline_entity_form/field_test/0&ajax_form=1&_wrapper_format=drupal_ajax
StatusText: OK
ResponseText: 

When this happens, the following messages are logged

Notice: Undefined index: field_collection_item in Drupal\field_collection\Plugin\Field\FieldWidget\FieldCollectionEmbedWidget::validate() (line 188 of /var/www/modules/contrib/field_collection/src/Plugin/Field/FieldWidget/FieldCollectionEmbedWidget.php).

Recoverable fatal error: Argument 1 passed to Drupal\Core\Entity\Entity\EntityFormDisplay::extractFormValues() must implement interface Drupal\Core\Entity\FieldableEntityInterface, null given, called in /var/www/modules/contrib/field_collection/src/Plugin/Field/FieldWidget/FieldCollectionEmbedWidget.php on line 191 and defined in Drupal\Core\Entity\Entity\EntityFormDisplay->extractFormValues() (line 223 of /var/www/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php).

If I attempt to save the node, including the newly created node with Inline Entity Form and the field collection which that node contains, I get a white screen with the generic "The website encountered an unexpected error" message and those same two messages in the logs.

I'm not sure if this would be most appropriate as a feature request, bug report, or support request (I feel like it has aspects of all three), but this is what I'm experiencing and it seems like incorrect behavior.

Comments

Anonymous’s picture

JKerschner created an issue. See original summary.

Anonymous’s picture

Title: Support nesting field collections inside entites re » Support nesting field collections inside entities referenced by Inline Entity Form
jmuzz’s picture

Version: 8.x-1.x-dev » 8.x-3.x-dev

Development is moving to 8.x-3.x.

Field collections extend entity reference in the new version so this behavior may have changed.

riddhi.addweb’s picture

tne_’s picture

Yes, this problem still exists and is really problematic when using Inline Entity Form; because once you have some field collections, there is no (easy) way back.

Has someone more insights into where to look to fix this? I am happy to help!

ram4nd’s picture

Status: Active » Closed (won't fix)
Issue tags: -Field collection, -Ajax, -inline entity form, -nested field collection