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.

Files: 
CommentFileSizeAuthor
#4 1845050-og-autocomeplete-tags-4.patch3.24 KBAmitaibu
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1845050-og-autocomeplete-tags-4.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Comments

I 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.

I 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?

Hi, 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).

  • Warning: Invalid argument supplied for foreach() in og_field_widget_form() (line 69 of /Applications/AMPPS/docroot/profiles/commons/modules/contrib/og/includes/og.field.inc).
  • Warning: Invalid argument supplied for foreach() in entityreference_field_widget_form() (line 815 of /Applications/AMPPS/docroot/profiles/commons/modules/contrib/entityreference/entityreference.module). (this error is repeated twice)

the entity reference is made if i type the full group name only.

Assigned:Unassigned» Amitaibu
Status:Active» Needs review
StatusFileSize
new3.24 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1845050-og-autocomeplete-tags-4.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Status:Needs review» Fixed

Fixed.

Status:Fixed» Needs review

#4: 1845050-og-autocomeplete-tags-4.patch queued for re-testing.

Priority:Normal» Minor

Please disregard re-test request. Inadvertently submitted.

Status:Needs review» Needs work

The last submitted patch, 1845050-og-autocomeplete-tags-4.patch, failed testing.

Status:Needs work» Fixed

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.