Problem/Motivation

I noticed some strange behavior with HS in a specific situation.

In our system we have functionality for the user to add new content or edit existing. It runs a Drupal.ajax call to our custom path which creates a fresh field_collection_item or loads an existing one and creates an ajax-enabled form for it through drupal_get_form and hook_form_FORM_ID_alter.
The form is injected to the webpage with ajax_command_html, by doing render($form). The resulting form is also submitted through ajax.

So all of this works perfectly fine. We can create/edit these field_collection_items, which hold a few text values and then a entity reference field to 1 node type with unlimited cardinality. Through Inline Entity Forms (IEF) inside this form users can administer those referenced nodes. It is these nodes that have several taxonomy terms, selected through the HS widget.
Of course these edit/create forms are also requested from Drupal through ajax, but this worked out of the box with no custom code once we had the correct field_collection_item forms in place.

Now for the part where the issue arises - whenever the same IEF form is requested the 2nd (or 3rd/4th/...) time, HS does not add the existing terms to the "selected items" list. It works fine on the first request and it works fine in the normal node form (of the nodes that contain this field_collection field).

Practically, there would be data loss after the user executed these actions (example):
-edit field collection (is presented with the fc_item's form through ajax)
-edit referenced node (is presented with IEF node form inside the fc_item form)
--2 terms in the term ref field are listed correctly
-cancel or save IEF form (2 terms are kept in the field)
-edit the same referenced node
--the term ref field is now empty
-users adds 1 new term to the field (he wants 3 terms in it)
-save node (IEF form disappears again)
-node now has only 1 term.

I haven't quite managed to figure out why but I assume it might have something to do with these forms being cached or delivered differently so that some of the HS widget code for the form isn't ran after the first request.

It's a very specific issue so also understand if this isn't important to fix, sadly enough we can't use your (amazing) module in our project with this bug in place.

Thanks in advance!

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Aethyx created an issue. See original summary.

stefan.r’s picture

Entity reference support is still very rudimentary, feel free to submit patches to improve upon this!

Gold’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

The issue summary is reasonably good but I am still having trouble figuring out how to set this up to replicate the issue.

If this is still an issue could the summary be updated with detailed steps to replicate the issue. Start from a clean D7 install with the Standard profile. List the modules you're adding, content types added/edited, any configuration needed etc.