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
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedJKerschner created an issue. See original summary.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #3
jmuzz CreditAttribution: jmuzz commentedDevelopment is moving to 8.x-3.x.
Field collections extend entity reference in the new version so this behavior may have changed.
Comment #4
riddhi.addweb CreditAttribution: riddhi.addweb commentedComment #5
tne_ CreditAttribution: tne_ commentedYes, 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!
Comment #6
ram4nd CreditAttribution: ram4nd as a volunteer commented