In trying to work on an issue from the Drupal Commons issue queue, I've eliminated Commons as the source of the issue and I think I've tracked it down to Organic Groups. In a fresh D7 site, If I install og and og_example, I'm able to reference existing groups when creating new Posts.
By default, the Groups audience field has "Default widget type" set to Select list. I'm able to choose from existing groups using the default widget. I'm also able to choose from existing groups, if I switch the Default widget type to Autocomplete or Check boxes/radio buttons. However, if I chose Autocomplete (Tags style), the following error appears at the top of the Create Post page:
Warning: Invalid argument supplied for foreach() in entityreference_field_widget_form() (line 815 of /path/to/docroot/sites/all/modules/contrib/entityreference/entityreference.module).
... and when I try to use the autocomplete field, nothing gets returned.
When I tried creating a reference field between two arbitrary nodes on a site without OG installed, the default Autocomplete (Tags style) widgets from Entity Reference don't seem to have this issue. It looks like the integration between OG and Entity Reference is bundled with OG, rather than with Entity Reference itself. I'll start looking at that code for clues next.
Comment | File | Size | Author |
---|---|---|---|
#4 | 1845050-og-autocomeplete-tags-4.patch | 3.24 KB | amitaibu |
Comments
Comment #1
Matt V. CreditAttribution: Matt V. commentedI found that you can get matches to return when using Autocomplete (Tags style), but only if you type in the full name of a group.
I noticed that the autocomplete path is getting set differently between the Autocomplete vs Autocomplete (Tags style). Using Autocomplete sets the path to /og/autocomplete/single/og_group_ref/node/post/default/NULL while Autocomplete (Tags style) is setting the path to /entityreference/autocomplete/tags/og_group_ref/node/post/NULL.
It seems that Autocomplete (Tags style) should be using the same /og/autocomplete/... format, but it's not getting set correctly. Instead, it's getting short circuited because the array returned by ctools_field_invoke_field does not contain the numerically keyed element that it does when dealing with an Autocomplete field.
I haven't yet tracked down where the numeric key is getting set for Autocomplete fields or why it's missing from the Autocomplete (Tags style) ones.
Comment #2
danielnolde CreditAttribution: danielnolde commentedI can confirm that "Autocomplete (Tags style)" is not working as described in #1.
#2 hints that some rewriting of the autocomplete callback path that's done by og for entity_reference's "single" style autocomplete has been forgotten for the "Tags style" autocomplete. Entity_reference's autocomplete handler cannot return anything because OG's entity reference selection mode doesn't story anything in the field's table (but uses OG's own table og_membership instead). Can anybody confirm this analysis, before we go into bugfixing this?
Comment #3
ryanrain CreditAttribution: ryanrain commentedHi, i get this same error on the edit screen for content that can be added to a group. ie. i haven't even tried to add the content to a group yet. i'm on a fresh commons dev install (Jan 2).
the entity reference is made if i type the full group name only.
Comment #4
amitaibuComment #5
amitaibuFixed.
Comment #6
bjprodneyl CreditAttribution: bjprodneyl commented#4: 1845050-og-autocomeplete-tags-4.patch queued for re-testing.
Comment #7
bjprodneyl CreditAttribution: bjprodneyl commentedPlease disregard re-test request. Inadvertently submitted.
Comment #9
amitaibu