I haven't tested with detecting context when used as a field or when embedding content via wyswiyg, but when using file entity's default file/add path and appending the og_group_ref link (which works fine with nodes on this project, mind you), the field does not populate. The argument does carry over to the second step after upload wherein you are editing the file entity item's fields, and even on refresh does not populate here (despite there being a properly configured field on this screen). The same thing happens on file/[fid]/edit. Straaange... hmm! Thoughts?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

rerooting’s picture

Would this be in the dev release? I tried again with the dev release and it wasn't happening either. I'll try checking out the latest git branch again later this afternoon. Thanks for the quick follow-up!

milos.kroulik’s picture

Version: 7.x-1.2 » 7.x-1.4
Issue summary: View changes

The problem still appears in 7.x-1.4 for me...

Is the only workaround available creation of new content type and using this to represent files?

ndobromirov’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
1.41 KB

This is a workaround that will work for file entities using the default widget.
Initial solution - it could be improved, but posting it as a working base.

Can not reproduce the edit issue on the last dev version.

bmunslow’s picture

Hi,

I'm experiencing this same bug with the 7.x-1.5 version of the module.

One way to get around it (without applying the patch) is by submitting the create/edit node form without clicking on the 'Upload' button of the file.

The file gets uploaded anyway and there's no error indicating that og_group_ref field must be populated.

Pol’s picture

Hello,

I've tested the patch on 7.x-1.5 and it doesn't work.

japerry’s picture

Had the same issue with 1.5 or dev.

I've made the following tweak based on how we use OG with events in COD. Not sure if it will work totally generically with all sites, although I suspect it will. I moved the ajax return callback to exist only in the form error section (where redirects were causing issues. There is also an entityreference form_state variable that works well for my use case.

ranroz’s picture

@japerry

Thanks for your comment. I tried using the code you gave here but still the issue remains.
What version are you using?

tien.xuan.vo’s picture

Here is the new patch. I re-write from #7 with some changes:

  • Support single or multiple values, default or custom multiple values behavior fields
  • Add unit tests

I also attach a patch for 7.x-1.5

meecect’s picture

I patched the dev version with #9 but it does not work for me. I am trying to prepopulate an og_group_ref field on a file entity, but neither creating a new file nor editing a file gets the group selection to prepopulate.

drumm’s picture

Status: Needs review » Needs work

It looks like the changes from #1958800: AJAX causes entityreference_prepopulate_get_values_from_url to fail affect this code too. The patch no longer applies, and that has a chance of also fixing this issue.

florisg’s picture

Reroll #7 for cod against 7.x-1.x #e9c16e4

joel_osc’s picture

I have tested with this patch and am still finding the field not prepopulating when using file/add.