When a user, member of groups 1 and 2, with OG permissions to create and edit "content" in both groups, creates a group content like this:

/node/add/content?og_group_ref=1,2

(og_group_ref Unlimited, and ERPrepopulate on), only one group is prepopulated.
Using:
/node/add/content?og_group_ref=1
or
/node/add/content?og_group_ref=2
works as expected.

Looking for a solution (it was working before upgrade, cannot remember if I applied any patch...)
Thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

inno81’s picture

FileSize
101.56 KB

It doesn't work only with OG audience fields.
With normal entity references, it works as expected.

Attached a screenshot which will hopefully explain the problem.

inno81’s picture

Reverting to version 7.x-1.2 solves the issues, but instead I get the Warnings:

Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /home/seriopla/public_html/includes/entity.inc).
Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 355 of /home/seriopla/public_html/includes/entity.inc).

It happens on every 'create node' page that has Group audience fields, multiplied by the number of values that I prepopulate.
- Drupal core 7.22
- Entity reference 7.x-1.0
- Organic groups 7.x-2.2+29-dev (2013-Jun-10)

Any ideas?

Renee S’s picture

I'm seeing this too. It doesn't like if there's more than one group selector on the page; I'm only prepopulating one group, but it seems to take exception to the fact that my pages have another group selector. It doesn't seem to affect anything, but does spawn an ugly error...

aleck_wi’s picture

Hi all

I have the same problem in my project. I am not a developer and any approaches were not successful. I have used stable release without success. I installed the latest dev and got the same.
I have traced the ERP module a little and saw that you lost the function call to get URL arguments because you had set $ids with last value of OG from URL before.
I have commented IF clause in // Check if there are values in the URL
and got required behaviour of module.
All that I can say in addition this is not a cache problem. I suppose that problem is in set of default value or in
IF clause
// Group audience field, but no field-mode provided.
// So we iterate over the "default" and possibly "admin" field-modes,
// and return those values together.

Please note that all is work fine only for List type field. A Autocomplete type field can get more than one value and this value is the smallest id from ids.

Best wishes

bluesky_still’s picture

I met those warings when user 7.x-22-dev
when use the newest 7.x-1.3, it works!

hosais’s picture

sub

aleck_wi’s picture

Hi I saw that my post were edited and some clarifications were added.
I want to provide answers on comments.

Check if there are values in the URL - All values are in URL and variable has required form.

Group audience field, but no field-mode provided.
So we iterate over the "default" and possibly "admin" field-modes,
and return those values together
This comment is a little bit unrecognizable for me because I am not a developer however I realized that you told about check box Entity reference prepopulate and other related setting.
I am using OG widget and in my configuration I have enabled Entity reference prepopulate checkbox, select hide if values in URL (they are there), fallback - do nothing, OG widget type - select list, Number of values - unlimited, target type -Node, Mode - organic groups, Bundles - doesn't set.
I had tried use another value in Mode - and set a Simple however without success.
Thank you for answer

jgraham’s picture

Status: Active » Needs review
FileSize
738 bytes

Posting here because my issue matches the title. However, my issue does not match issue as described so I am not sure if this is the same or a separate issue.

My issue is trying to prepopulate on node add for two separate groups referenced via two different fields. That is I want to add a new node that is a member of two different groups referenced via two different fields. This matches the title. The initial description however describe multiple groups in the same field.

The issue appears to be that the og_context setting of a field is ignored. Note that this issue is only present if the og_context module is enabled.

Patch provided checks the prepopulate settings to ensure the widget should respect og_context when determining prepopulate ids.

Sorry if this is a separate issue, like I described above my issue matched the title.

Status: Needs review » Needs work

The last submitted patch, entityreference_prepopulate-2033937-7.patch, failed testing.

jgraham’s picture

I think the test is broken. It doesn't run successfully with or without this patch on a minimal install.

Leaving as needs work for review of the test.

pianomansam’s picture

Yuri’s picture

I confirm that the issue is present with regard to two different entity reference fields on the same node that have entity reference prepopulate enabled (in my case the organic group behavior setting did not matter for this issue).

I also confirm that applying the patch at #8 manually solves this issue, both fields are prepopulated. Thank you jgraham!

With regard to the possible relation mentioned in #11, that refers to an error like Warning: array_flip() that I do remember seeing now and then, but for which I couldn't find a solution in the issues. I will report if I still encounter error messages of this kind. For now I'm VERY happy!

guillaumev’s picture

I believe that when this issue:

https://drupal.org/node/2025199

gets fixed, it will also automatically fix this one.

amitaibu’s picture

Issue summary: View changes

Can you please confirm if this issue still exists after #2162811: Add "Providers" functionality, and allow settings weight on them got in.

Yuri’s picture

After applying patch #8, it works, other patches didnt have effect in my case. But somehow it reappeared a few days ago in my site. I have no idea how that happened. I cloned the content type in order to check..strangely enough the prepopulation of the field worked in the clone.
The solution appeared to be to change the widget type, save and change the widget type back again. That made it work.

howards’s picture

When I read the original issue, it looks like the issue's title may be misleading. From how I read the original issue, it looks like the issue isn't multiple OG audience fields, rather multiple values within a single audience field. (Hence the "?og_group_ref=1,2" rather than "?og_group_ref=1&og_second_group_ref=2") I may be reading it wrong, but I'm experiencing issues with multiple values on a single OG audience field as described.

It looks like the issue still exists in 7.x-1.5. In the testing I've been doing over the last hour or so, it appears prepopulation works on certain types of entityreference fields, but not necessarily on others.

One of my tests used a multivalue checkbox selection of target-type "taxonomy terms" and used an entity selection method of entityreference view to generate a list of appropriate terms. URL prepopulation worked with multiple values in that case.

The URL prepopulation test, on a multivalue field with target-type "Node" using entity selection of "Organic Groups" appears not to work with multiple values. In that case, it appears URL prepopulation only picks up the final value in a multiple value list for an og audience field.

Thinking about it, perhaps this is a non-issue if the entity selection method can simply be an entity reference view with a filter for the "group_group" field? (Might that be an appropriate workaround, or are there other logistical issues handled by the "organic groups" entity selection method?)

EDIT: In addition to filtering on group_group, also looking at contextual arguments to relate to the og_user_node and come up with the matching nodes to create a list of "my groups"?

EDIT #2: It appears when using URL prepop with groups administrative privileges, it stores the final value (of multiple values) in "other groups," while using an account without groups administration privileges stores the final value appropriately in "Your groups." ... If that makes a difference.

ionut.stan’s picture

My issue with OG and Entityreference prepopulate was that when I activated the Entity reference prepopulate option on the OG field, the prepopulation was not actually working. The Group field didn't get pre-filled with the group id from the URL.
I managed to solve this by changing the Widget type from OG Reference to Selection list.

WorldFallz’s picture

I can confirm ionut.stan's findings-- switching the widget from OG Reference to Selection list allows multiple groups to be specified via entityreference_prepopulate links with commas.